I would like to make a script, where I specify my Cisco devices IP addresses as arguments to the script and then this script automatically logs into every one of them and does "show version" and "exit" in every Cisco device. I have public/private key authentication system with my Cisco devices- thats why I'm using
ssh-agent and
ssh-add. I did something like this:
Code:
#!/bin/bash
if [ -z $1 ]; then
echo USAGE:
echo "$0 IP1 IP2 IP3 IPn"
else
eval `ssh-agent` >& /dev/null
ssh-add
for i in "$@"; do
ssh $i
show version
exit
done
fi
However, it logs nicely into the first device(I'm able to execute IOS commands in this first Cisco device etc) and then does nothing further. Any ideas?