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"