Les Mikesell wrote:
I'm still missing why you'd need to sudo inside the remote shell instead of ssh'ing as the right user in the first place.
Perhaps he doesn't know the user@ syntax.
Tony, try this:
[localuser@host1 ~]$ ssh root@host2 remotecmd
This requires that the public key for localuser on host1 exists in host2:.ssh/authorized_keys. It also requires "PermitRootLogin yes" in /etc/ssh/sshd_config, which is unfortunately the default on CentOS. (I usually turn it off.)
Beware that this makes localuser on host1 equivalent to root on host2!
Also realize that remotecmd can be a very complex thing, not just a simple command. You can use pipes and other things through ssh.