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 abcuser@test-server.net '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.

sudo su [username]shouldn't require a password. It would be the same as, while logged in as root, runningsu [username]. – newfurniturey Jul 19 '12 at 20:27xyzuser. But what you're trying achieve is a bad practice. – triclosan Jul 19 '12 at 20:27sudo command– c0mrade Jul 19 '12 at 20:46man sudoersfor details. – FatalError Jul 19 '12 at 20:48