Automate file uploads to your Cisco Nexus switches

Note from the author: No artificial intelligence (AI) was used to write this blog.
However, being a non-native English speaker, I may have used a translator or grammar corrector in some cases, which may have altered my natural way of writing. Thank you for your understanding.

If you have more than three Cisco Nexus switches in nx-os mode, and you are not using Cisco DCNM or any other similar tool, you probably already have encountered this question: How to automate file uploads to your Cisco Nexus switches?

Here is a turnkey Python script using Netmiko’s SCP function to do this.

This script is very simple, it relies only on Netmiko functions and SCP. But it does its job very well and I share it here because it can certainly help you to save time.


What is Netmiko?

If you want to know more about Netmiko, here is the git page of its creator, Kirk Byers:

On my side, I’ve already written a post on this blog about another script I created based on Netmiko.

I can’t thank Kirk Byers enough for his huge contribution on automation for network engineers. And I recommend you check out his web site and, as I wrote in a previous article about network automation, take his free Python course for network engineers.


Get the script

So, how to automate file uploads to your Cisco Nexus switches?

The script is available on my git page, here:

It is based on Kirk’s example, available here:

How to use it?

To use this script, you must have SCP on your machine. Sorry Windows users but I did not tested this with WinSCP or anything similar. Use this script on a Linux machine or container.

Then, make a git clone of my git repository above and edit the script. There are two lines to adapt to your environment:

  • Line 6: you can put here the list of your Nexus switches. If needed, you can replace this by an external file or inventory tool. There is no limit here.
sw_list = ['', '', '']
  • Line 9: you must specify here the nx-os binary file and it’s location. Here I put as example a local file in the same directory of the script.
source_file = "./put_your_nxos_file_here.bin"

Note: to make a test, you can use a small txt file of two or three lines, before uploading a very large nx-os binary file.


See it in action – upload files!

Once you’ve done that, run the script:

$ ./

For each host, you have to confirm you want do the upload. You can stop the script with Ctrl-C.

Then, for each switch, the output will give you three information:

  1. Does the file already exist on the remote switch? (true or false)
  2. Has the file been transferred? (true or false) – if it already exists, it will not be transferred.
  3. Is the MD5 checksum of the file correct? (true or false)

Here is an example of the output:

$ ./ 
Please insert your Nexus username: test
And your password
Upload on:
Hit enter to continue or Ctrl C to stop: 
File exists already:  False
File transferred:  True
MD5 verified : True
Upload on
Hit enter to continue or Ctrl C to stop: 
File exists already:  False
File transferred:  True
MD5 verified : True
All copy are done

If the file already exists, you will have the following output:

File exists already:  True
File transferred:  False
MD5 verified : True

As you can see, this script can also be used to just make a MD5 checksum comparison.

Happy uploading!


Update May 2021:

I updated this script with more features, including multi-threading.

You can clone it from here:


Did you like this article? Please share it…

2 Thoughts to “Automate file uploads to your Cisco Nexus switches”

  1. Istvan


    I suggest to use threading. It speeds up the task. Upto 30 concurrent connection the performance per thread is as good as if it were just one. I do connect to 500 nodes at the same time. Here is a little performance drawback per thread, but it is still much much faster.

    1. Hi Istvan,

      Thank you for your comment, you were right.
      Now, I updated this script with multi-threading, check here:


Leave a Comment