cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3209
Views
4
Helpful
5
Replies

ssh command execution

MZydorczyk2
Level 1
Level 1

Is there a way to execute commands on a cisco device by giving only one ssh command from a computer?

5 Replies 5

ggilbert
Cisco Employee
Cisco Employee

Hi,

Can you please explain to me what you are trying to do.

Normally SSH is used to get management access to the device.

Do you want to do something after that?

Thanks

Gilbert

Yes. I want to be able to execute commands on the device from the computer by only having to type one command. I dont want to have to login and then configure the device.

For instance:

ssh -l -v "sh ver"

at the computer would connect to the device, ask for the password and execute the command all in that one command. However I can only get it to take one command. Is there a way to like run a list of commands you want to execute on the device? Or is there something else I could do to automate the ssh session?

hoogen_82
Level 4
Level 4

First your router should support ssh function. For this make sure you IOS shows a k9 in it. Or else download a suitable one.

Then generate the crypto rsa keys on the router/device. crypto key generate rsa. Specify if neccessary the ip ssh authentication retries and timeout seconds.

Leter download a software like putty or secure crt to connect to these devices from your PC.

HTH

Hoogen

This is for any cisco device not routers in particular. Also I know how to setup and use ssh but I want a way to automate it. Like i mentioned in the other reply above

Hi Matthew,

I understand what you are saying - To be honest with you, I do not know if an SSH single line entry is there to automate such a process you are requesting...

But there is an option in IOS called as "Embedded Event Manager" (EEM) -

Please take a look at it. See if this is something that would help you out.

http://www.cisco.com/en/US/products/sw/iosswrel/ps5207/products_command_reference_chapter09186a00801a8085.html

Cheers

Gilbert

Note: I had never used it before but playing around with it might help or atleast give you an idea. Sorry for not giving you a direct answer.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: