In one section of a bash script, I need to ssh into a remote box, change to root, then deploy an rpm. My code is getting stuck after it changes to root and I'm not sure why. Any help would be greatly appreciated. Ideally I would like it to ssh in, switch to root, deploy the rpm, then exit the ssh session.
user="user"
host="hostname"
echo "Enter password: "
read -s pw
ssh -t "$user"@"$host" "sudo su; $pw; rpm -Uvh rpmtodeploy.rpm;"
This is what I get currently:
user@localhost:~$ bash rpm.sh
Enter password:
[root@hostname /home/user]#