Can not telnet/ssh to switches directly. Can only ssh into a ASR/switch then from the switch ssh to each switch.
ACL only allows ASR device to SSH to each switch.
This can be done with a for loop within the "expectscript.exp" script.
Create a file with the names/IP’s of the devcies you want to connect to from the ASR:
STEPS:
1. [root@localhost script]# vi device-list
10.x.x.1
10.x.x.2
10.x.x.3
10.x.x.4
2. [root@localhost script]# vi from-one-device-TO-ALL-others.exp
#!/usr/bin/expect -f
# Set variables - some of which were sent from the calling bash script
set hostname [lindex $argv 0]
set username "YOURUSERNAME"
set password [lindex $argv 1]
set enablepassword [lindex $argv 2]
set timeout 5
# Where to put the Log file results
log_file -a /root/script/results.log
spawn ssh -o StrictHostKeyChecking=no $username\@$hostname
expect "*assword: "
send "$password\r"
# SSH to each IP/Hostname in local file named "device-list", do a "show clock", then exit
set devicelist [open device-list]
while {[gets $devicelist line] != -1} {
expect "*>"
send "ssh $line \n"
expect "Password:"
send "$password\r"
expect "*>"
send "show clock\n"
expect "*>"
send "exit\n"
expect "*>"
}
close $devicelist
send "exit\n"
expect ":~\$"
exit
3. Now RUN it:
[root@localhost script]# ./from-one-device-TO-ALL-others.exp
No comments:
Post a Comment