Pscp – Transfer/Copy Files to Multiple Linux Servers Using Single Shell

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

12 Responses

  1. Ashwini R says:

    It didn’t work for me as well. I can get into the machine through same ip and port as I’ve inserted into hosts.txt file. Still i get the below messages:

    [[email protected] ~]# pscp -h myscphosts.txt root -Av LoadKafkaRN.jar /home/
    [1] 13:37:42 [FAILURE] Exited with error code 1
    [2] 13:37:42 [FAILURE] Exited with error code 1
    [3] 13:37:42 [FAILURE] Exited with error code 1
    [4] 13:37:42 [FAILURE] Exited with error code 1
  2. Sai Sudheer says:


    I have a shell script which will split the input dump to multiple files, and I want to know logic to transfer these files to multiple servers equally, as per above command source files will be transferred to all multiple servers.

    But my requirement is to avoid duplication, and copy files to destination servers equally. for exp: 16 input files to 4 servers– so that each server will get 4 files.

    my input dump changes time to time so that local files may become any numbers. Please help for solution.

  3. Ankit Tiwari says:

    I am following this tutorial to copy a file to multiple system but its giving error. The code i am using is
    pscp -h myhost.txt -l zabbix -Av show-image-1920×1080.jpg /home/zabbix/
    but it gives error
    [1] 11:18:50 [FAILURE] Exited with error code 1

    • Ravi Saive says:


      Have you placed correct remote SSH host IP address and port number in the myscphosts.txt file? please confirm and add correct values and then try again..

  4. jHz says:


    I am trying to copy one file from 30 hosts to one central computer by following you article but no success.
    I am using pscp command for this purpose:

    pscp -h hosts.txt /camera/1.jpg /camera/1.jpg

    where camera directory has been created already in which 1.jpg exists. It always give me error:

    Exited with error code 1

    I have also tried pscp command to copy file from one host to server:

    pscp -H “” /camera/1.jpg /camera/1.jpg

    but it also returned me with the same error.

    Any help will be much appreciated.
    Thanks in advance.

    • Ravi Saive says:


      Have you created “myscphosts.txt” file on local machine with list of remote Linux server IP addresses and their respective SSH ports? and the correct command to copy the file from local to remote is:

      # pscp -h myscphosts.txt -l tecmint -Av wine-1.7.55.tar.bz2 /tmp/
      # pscp.pssh -h myscphosts.txt -l tecmint -Av wine-1.7.55.tar.bz2 /tmp/

      explanation about the options used in the above command.

      -h switch used to read a hosts from a given file and location.
      -l switch reads a default username on all hosts that do not define a specific user.
      -A switch tells pscp ask for a password and send to ssh.
      -v switch is used to run pscp in verbose mode.

      • jHz says:

        Yes I have created hosts ip file in which I saved all ips with port numbers. I am using the same command and syntax but it returns me with error: Exited with error code 1.

        • Ravi Saive says:


          You were using wrong -H switch and also you didn’t mentioned about -l option used to specify username to connect to the server, I suggest you to run the commands which I given in the comments…and see.

  5. anil says:

    Above article is not working in ubuntu 12.04

    • Ravi Saive says:


      Sorry for trouble, could you please tell us why it’s not working? did you get any error while installing? Please share with us your problem, so that we can help you out..

  6. Jalal Hajigholamali says:

    Thanks a lot
    Very nice and useful article
    Thanks again

Leave a Reply to Cody Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.