I wanted to sudo to different user after ssh'ing into remote server, for this i tried the following:
cat remote-test.sh ssh -t -t firstname.lastname@example.org 'bash -s' << EOF /tmp/test.sh EOF
when i execute the remote-test.sh from development-server.net, I wanted to ssh to test-server.net as abcuser and then sudo as xyzuser .
cat /tmp/test.sh echo "password" | sudo -S su - xyzuser cd /tmp/some/directory
Can someone please advice how to pass a password while doing sudo su in a script.