3
1
As part of my normal workflow I ssh into another user's machine, switch user to them, run a command, then exit out to my own machine again:
ssh hostname
sudo su user
runcommand
exit
exit
Is there a way to cut this down to a single line command? e.g.
ssh --someflags "runcommand"
I have tried this but get prompted for the other user's password which I do not have:
sudo ssh user@hostnme "runcommand"
Something like
ssh myaccount@somehost "su -u <user> -c <command>"
wouldn't work? – Fiisch – 2013-10-04T18:56:03.923You could always publish your key into their authorized_keys file. Then you can connect to using that users account directly. – Zoredache – 2013-10-04T19:28:39.117