I am trying to SSH a remote machine and change user to root and run a series of command which need root
I tried the command below but seems it's not working
sshpass -p <pwd> ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null <user>@$IP "echo <pwd>| sudo -S su; whoami"
whoami always return instead of root
Any idea how to get it done?
edit
echo <pwd> | sudo -S <some-command> always work in this case, but not with sudo -S su ?