Wednesday, 14 June 2017

Copying files from Linux to a Cisco Router/Switch via SCP

I recently needed to transfer a license file to a Cisco 2911 and explored the options available apart from FTP. Luckily, I discovered that Cisco routers can act as SCP servers. Of course this means you need to have SSH (version 2 as good practice) enabled on the router first and aaa new-model configured including aaa authorization. The command (in global config mode) to turn on SCP on the router is simply:
ip scp server enable
Please note that only having the user with privilege 15 won't allow you to copy the files, you will get a Privilege denied error on the client scp side like below (run the scp command with the -v switch for debugging) 
        debug1: Sending command: scp -v -t flash:/licenses/license.lic
Privilege denied.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to x.x.x.x closed by remote host.
Transferred: sent 2912, received 3872 bytes, in 7.4 seconds
Bytes per second: sent 396.0, received 526.6
debug1: Exit status 0

To resolve the above error, ensure you have this in your aaa configuration 
aaa authorization exec default local none

You can now go ahead and copy the files you need via scp just like you're copying them to/from another Linux machine, i.e. the command format does not change.

  As always, do not forget to save your configuration in the event that you need the functionality you've added later, e.g for regular backups over scp from the router to a server. Otherwise, you can undo the changes when you're done copying your files to the router.

Cisco Router configuration using SNMP

Recently, I was faced with a challenge whereby I was unable to access some of our routers via SSH. Routers that we have been able to access ...