Solved

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

Posted on 2013-01-28
7
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

734 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