Solved

"ssh user@host command" runs under a different user?

Posted on 2013-01-28
7
381 Views
Last Modified: 2013-01-28
Hi there,

I'm trying to use "ssh user@host command" to run a command on host as user.  However it looks like the command is running under a different user.  Anyone can confirm this or did I miss anything?

Thanks.

Tom
0
Comment
Question by:thomaszhwang
  • 3
  • 3
7 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 375 total points
ID: 38826649
No, it doesn't run under a different user.

Verify with

ssh user@host id

or

ssh -tt user@host who am i

Could it be that user doesn't have the same privileges on host as on the local machine?
0
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 125 total points
ID: 38826938
Just to make sure that ssh was successful, make sure you are where you expected.

issue commands
whoami
hostname -f
0
 

Author Comment

by:thomaszhwang
ID: 38826964
I just tried "ssh user@host 'whoami'" and it return user, so it means the user is the correct user.

I also tried to run the command separately: run "ssh user@host" first and then "command" and everything is ok.

Any idea?  Thanks.

Tom
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 375 total points
ID: 38826979
So why do you think that you're running the remote command under a different user?

Any error messages?

Is the remote user a member of the same group(s) as on the local machine?
Is the numerical user id the same on both machines?

That's why I suggested running "id".
0
 

Author Comment

by:thomaszhwang
ID: 38827035
I just tried again.  The id returns the correct result.

The reason why I think it might be running under a different user is because the command I tried to run is a Pig Latin script which requires a valid version of Java and the error message reported Java_Home is missing, which is very typical when I tried to run such script under a different user or run under sudo which has a different JAVA_HOME setting.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 375 total points
ID: 38827051
It rather seems that the user in question doesn't have the correct settings in their profile on the remote machine!
0
 

Author Closing Comment

by:thomaszhwang
ID: 38827078
Thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question