Solved

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

Posted on 2013-01-28
7
387 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

705 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