cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1032
Views
0
Helpful
1
Replies

PSSH Linux

Aaron.Pittenger
Level 1
Level 1

Hey Everyone,

I've got 90+ switches running SSH and I want to (temporarily) enable http secure-server and then disable it (as well as run a few other commands).

Right now my only path into the switches is via SSH.

Rather than sit for hours doing this manually, I'm trying to automate this using the PSSH tool for linux.  Everything (almost) works, but I keep getting a stderr right before my cisco login banner appears.  I'm not sure if it is a result of the banner appearing, or something else.

I'm logging in by passing my username and then have the -A switch so it prompts for a password.  If I pass a command such as 'sh run', it gets a few lines in before giving a stderr, displaying the banner (which usually comes up before a login prompt) and then terminates.

Any ideas on how to work around this?

Thanks,

Aaron

1 Reply 1

Philip D'Ath
VIP Alumni
VIP Alumni

What is the stderr that you get?

Here is a script that does something similar using telnet.  I'm sure you can modify it to use ssh.

proc_sendcommands()
{
# Change host details here
rt_host=$1
rt_username=$USERNAME
rt_password=$PASSWORD
rt_command_0="sh conf"
rt_command_1="sh hardware"
rt_command_2=""
rt_command_3=""
rt_command_4=""
rt_command_5=""
rt_command_6=""
rt_command_7=""
rt_command_8=""
rt_command_9=""
rt_command_10=""
rt_command_11=""
rt_command_12=""
rt_command_13=""
rt_command_14=""

(sleep 3; echo $rt_username; sleep 3; echo $rt_password; sleep 1;echo $rt_command_0;sleep 1;echo $rt_command_1;sleep 1;echo $rt_command_2;sleep 1;echo $rt_command_3;sleep 1; echo $rt_command_4;sleep 1; echo $rt_command_5;sleep 1; echo $rt_command_6;sleep 1; echo $rt_command_7;echo $rt_command_8;sleep 1;echo $rt_command_9;sleep 1;echo $rt_command_10;sleep 1;echo $rt_command_11;sleep 1;echo $rt_command_12;sleep 1;echo $rt_command_13;sleep 1;echo $rt_command_14;sleep 10; echo "exit" ) | telnet $rt_host

}

#-----------------------------------------------------------------------------
# Main


IP_LIST=$1
USERNAME=cisco
PASSWORD=cisco

cat $IP_LIST | while read IP
do
echo Processing $IP
proc_sendcommands $IP


# Execute and send results to a file
# proc_sendcommands $IP > $IP.cfg
done

Review Cisco Networking for a $25 gift card