LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2011, 09:34 PM   #1
amcohen
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Rep: Reputation: Disabled
ssh "user@host cmd" from root


I’ve used your method to ssh without a password for a non-root user, say “user”. This works as long as I’m logged in as “user”.
But if I run as root, the following still asks for “user”‘s password.
i.e.: the following works w/o a password:
su – user
ssh host date
But the following asks to the password of “user”:
su – root
ssh user@host date
 
Old 07-11-2011, 10:52 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
I'd have to guess that you've set up ssh key based authentication for root@host not user@host ... as these are 2 different users on the remote system you'll need to set it up for both.
 
Old 07-12-2011, 01:42 AM   #3
amcohen
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
I copied the .ssh/authorized_key2 file under the "user" account onto the remote host. That's why if I become "user" on local host, I can ssh to user@remotehost without a password. What I'm actuaaly trying to do is to write to tape on the remote host; the local host is Solaris 10 while the remote host is RHEL 5.6; e. g.:
cd /; /bin/tar Ecfb - 200 opt | ssh user@remotehost 'dd of=/dev/nst0 bs=200b'
 
Old 07-12-2011, 01:56 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
ssh works on a pair of keys.
The user's (local) key is only visible from the user's acct, not the root acct.
I think you want (if starting from root)
Code:
su - user -c "ssh user@remotehost ..."
theoretically you can skip 'user' part of ssh cmd, as it'll default to current user, if that's what you want.
http://linux.die.net/man/1/su
 
Old 07-12-2011, 12:04 PM   #5
amcohen
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
That worked!

That worked, thank you very much:
e.g.: su - user -c "ssh remotehost uname -a"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command logging ideas needed! ssh user@host "echo logme" ZiGz Linux - Security 6 04-15-2009 03:08 AM
How to disable remore ssh login access of "root" user. ashishshukla Linux - General 3 10-07-2008 09:55 AM
SSH Keybased authentication for "root" user on linux. adastane Linux - Networking 2 12-13-2007 04:57 AM
"Can't resolve host" as user, but works fine as root truthe Linux - Networking 2 10-22-2006 06:41 PM
"su root" fails when I connect with normal user thru SSH AlinFaur Linux - Security 5 02-23-2006 12:26 AM


All times are GMT -5. The time now is 05:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration