Solved

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

Posted on 2013-01-28
7
378 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 375 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now