Categories: Cisco , Cisco Routers , SSH -  Comments
Before getting started with this little tip, I just wanted to drop a short note to you all to let you know that James and I have not abandoned the blog. We have just taken an “unannounced” three month vacation. Or you could say that “life happened” to us both and three months slipped by.
I have been trying to find the time to put together something really impressive after being out for so long, but I have decided it is better to just get back to work. As a way of getting back into the swing of things, I thought I would do a small writeup on an IOS feature that I recently stumbled across. I have known for a while that it is possible to pass commands between Linux machines via ssh by simply adding a command to the end of the ssh command string. I recently tried it on a router and to my surprise … it worked. Cool!
For example, if you want to see a show version from another router, simply add “show version” to the end of the ssh client command.
From another router with the username of root
router#ssh -l root 10.10.10.1 “show version”
From a Linux or Cygwin terminal to a router with the username of root
[root@vmware1 ~]# ssh email@example.com “show version”
If you want to retrieve the show version command from several routers. You can use a single line script in a Linux shell or Cygwin. The following command will loop through routers 10.10.10.21, 10.10.10.22 and 10.10.10.23 running the ‘show version’ command.
for ip in 10.10.10.21 10.10.10.22 10.10.10.23; do ssh root@$ip “show version”; done
There are lots of more interesting things to be done with scripts, but I thought I would keep it simple. If anyone finds a way to login automatically or make configuration changes with this trick, please let me know.