I'm searching high and low for a simple script to just loop through a series of servers. I don't want to run additional commands automatically, but that's all I'm finding. I don't need to while. I just want to have it SSH to the server and allow me to do work on it, then when I exit it goes to the next one. I've done this before but it was on an old debian box and now I'm using ubuntu
#!/bin/bash
for IP in `cat /home/bb/server.txt`
do echo $IP
ssh -p 2202 $IP
done
I've tried modifications of other scripts people post such as
#!/bin/bash
servers="/home/bb/server.txt"
while IFS= read -r server
do
echo "connecting ... $server"
ssh -p 2202 "$server"
done < "$servers"
but this just spins through them all and doesn't let me work inside any of the servers.
Edit1: the first loop just echos the file location and not the server so its not opening the file to read the hostnames. additionally it comes back with Could not resolve hostname cat, which confirms it is not reading it.
Edit2: I am trying to avoid installing new software as that is frowned upon on these servers.
Edit3: As for my end goal I'll try to be more detailed. I have work to be done on a list of servers. The work is different on each, but they all have stuff that needs to be done. Instead of going off a list of hostnames (58 of them) and potentially missing one, having a script connect me to the next one is more convenient. I just need the script to ssh me to one server, then when I'm done and exit out via exit
or ctrl+d
it ssh to the next one