Obligatory \'first post\' tag. Issue: Commands will not pass to command line after entering password for a sudo su - userB
I am writing a s
su creates a subshell that reads the commands from standard input by default. It executes whoami after that exits. You can use the -c option to pass a command to it.
ssh -qt -p22 userA@hostname "whoami; sudo su - userB -c 'whoami'"
You can also use the -u option to sudo instead of using su:
ssh -qt -p22 userA@hostname "whoami; sudo -u userB whoami"