Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSH to a cisco router and capture a show command

Status
Not open for further replies.

netman4u

Technical User
Mar 16, 2005
176
US
Hello all,

I am writing a perl script a part of which is to SSH to a router, run a show command and capture the STDOUT of the command. Can I do this with a shell command?

I have tried:

Code:
my $password = 'password';
my $user = 'auser';
my $ip = '100.152.201.22';
my $results=`"(echo $password) | ssh $user@$ip"`;

However it still prompt me for a password when I run it and it does not even try to log me in as 'auser'.

Any help is appriciated.

Nick


If at first you don't succeed, don't try skydiving.
 
Thanks for the quick reply.

From your link:

The public portion of this key pair will reside on the servers being connected to

I am connecting to a router via SSH not a server. How can the router hold a key?

If at first you don't succeed, don't try skydiving.
 
You could use an expect script to enter the password.

I'm surprised that if the router supports SSH it has no facility for storing the keys...?

Annihilannic.
 
To generate the key on the router use.

cry key generate rsa
ip ssh time-out 60
ip ssh authentication-retries 2

At this point, the show cry key mypubkey rsa command will show the generated key.


Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top