At my job, the only way that I can switch users is by doing the following:
sudo su - *USER*
In order to run multiple commands as the user (in a script or something), I use here strings and here docs:
sudo su - *USER* <<< 'ls ; whoami'
Since I frequently have to log in as a user and then ssh to a server, I want to make an alias to do this in one shot, but I can't figure out how. My best guess is this, which doesn't work (it logs me in but I can't run commands):
sudo su - *USER* <<< 'ssh -tty *SERVER*'
I've also tried:
sudo su - *USER* <<< 'ssh -tty *SERVER* < /dev/null'
and
sudo su - *USER* <<< 'ssh -tty *SERVER* bash'
I think I am misunderstanding something either about ssh or su. Let me know your thoughts!
sudo su -l USER?sudo su -l USERworks: it gives me a shell prompt as the designated user. @EduardoTrápani's advice is correct: if you use<<<you won't be able to use the terminal, and the converse.