Ssh – How to make a bash script wait after running SSH command

bashssh

I am currently writing a bash script to help me update some servers, so I need to connect there, run yum update -y and then sometimes type in additional commands. I do currently have this set up:

for servers in $devservers
    do
        ssh $servers 'yum update -y'
    done

But the problem is that when I run this, it won't allow me to write some additional commands in case I need to – like when I need to restart certain services. Is there a way to make the script wait for me until I log out of the server?

Best Answer

If you need shell access after the yum ends, you need to run a bash or your preferred shell. Also using -t will help you to work properly (allocate remote TTY).

for servers in $devservers
    do
        ssh -t $servers 'yum update -y;bash'
    done