Solved

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

Posted on 2013-01-28
7
383 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux boot cd to do hardware report on PC? 3 76
awk sed 8 102
Quickest way to query Windows Event ID from a Linux Device 3 69
AWS Linux EC2 question on group 7 9
Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

735 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