How do I securely transfer files from one UNIX / Linux server to another UNIX server using Windows or Linux desktop clients without using ftp client?

You need to use secure sftp or scp client for Windows XP / Vista / 7. Under Linux or Apple Mac OS X desktop you can use regular OpenSSH scp / sftp client to transfer files.

Windows SSH Client

You can use free SFTP, FTP and SCP client for Windows called putty or winscp.

Windows Winscp transfer files from one UNIX / Linux server to another

Fig.01: Winscp transfer files from one UNIX server to another (image credit Winscp website)

Linux / UNIX / OS X SSH scp Client Examples

Use the following command from the server to which you want the files to go. In this example, transfer all files (/var/www/html) from remote server called server1 to local directory called /backup:
scp -r user@server1:/var/www/html/ /backup
In the following example, transfer all files (/var/www/html) from remote server called server1 to another server called server2:
scp -r user@server1:/var/www/html/ user@server2:/var/www/html/

Say hello to rsync

I recommend using rsync command which will only push or download updated files. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. In this example, copy files from remote server called server1 into /backup directory:
rsync -avz -e ssh user@server1:/var/www/html /backup

See also:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 27 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
27 comments… add one
  • cyberciti-subscriber Feb 16, 2010 @ 14:28

    Expecting more Quality posts from you .. not like this one for the sake of posting.

  • Shivam Garg Feb 16, 2010 @ 14:46

    Thx greate tutorial……………………Keep it up.

  • Liju Mathew Feb 16, 2010 @ 16:20

    putty– SSH client tool which is the powerful one
    winscp — ssh GUI tool , mostly useful for secured file transferring but not good for large file transfer.
    sftp : secured ftp file transfer
    vnc over ssh tunnel : secured Linux GUI administration
    lftp : FTP synchronization tool, which is a great helpful to admins to keep the incremental file synchronization over FTP.
    webdev+https : secured file sharing over the web, can be used as mapped network

  • Israel Feb 17, 2010 @ 1:30

    Umm, I’m getting this error:

    vps200:/tmp# scp -r root@vps204:/var/tmp/host-test root@vps243:/tmp/
    Host key verification failed.
    lost connection

    • Simi Nov 11, 2011 @ 6:38

      I got the same error too, i later modified to just
      scp -r /var/tmp/host/ user@server:/var/tmp/host/whatever
      It just asked me for the target server’s password and then copied.

  • jay Feb 17, 2010 @ 2:05

    How about tranferring or downloading file from remote linux server to Windows machine?
    I used Winscp GUI tool but im still looking for a ways to do it by just running ascript.

    So far this is what I have in Windows machine:

    winscp> open
    winscp> get /root/file.txt //to download file fom the linux server
    winscp> put D:\file.txt /home/user1 //to upload file

    I am still looking for a way to specify the destination directory in the “get” command
    and how to rename the file in a desired format when I “put” the file in the linux server.

    Any help will be appreciated.

    • pankaj negi Jun 11, 2011 @ 2:32


      I implemented same setup recently for one of my clienet.

      You need to write a VBScript or cmd or powershell, that will first convert the file name or extension based on your requirement and then you could pass file to unix enviorment using WINSCP (Command line or GUI, unattended and attended respectivily).

      Let me know in case of any issue.

      Pankaj Negi

  • Shivam Garg Feb 17, 2010 @ 8:54

    try to run command with -v attribute . it will give us some information to debug..

    Is shell demading for any password for both of the server???

  • max Feb 25, 2010 @ 11:58

    you can also try pscp.exe, which is a command line tool

    d:\Distors\pscp.exe -r user@server1:/var/tmp/deb.iso .


  • bibin varghese Mar 3, 2010 @ 9:33

    how can u securely transfer a file from one server to another in linux?

  • Shivam Garg Mar 4, 2010 @ 5:17

    You can use scp command to copy ……..

    scp -r user@server1:/var/www/html/ user@server2:/var/www/html/

  • sunardo Apr 1, 2010 @ 3:12

    Filezilla FTP client

  • chuck scott Sep 29, 2010 @ 0:20

    Hola Vivek Gite … a BIG THank You on this post and your sharing the command line scp -r user@server1:dir-path examples … this worked brilliantly and i just got done migrating 26+ gigs of domain files from server01 to new server02 via your command line method …

    as fyi, i started at 10AM trying to do it via two open sessions of WinSCP but stopped after 12% of one of the 11 gig tar files on server01 ran and ran only to discover that WinSCP method was downloading the tar to my local machine (which was not NTFS drive thus would have crashed with 2 / 4 gig win fat32 limits) and then uploading it onto the new server02 which was useless …

    so around noon i cancelled said silliness, opened WinSCP as root on server02, launched Putty from within WinSCP, and started command line per your examples … 8 hours later, it looks like all tar.gz data files from domains on server01 are nicely arrived and awaiting to be untar’d into new domain areas on server02 ;)

    muchas gracias … cordially, chuck scott

    ps – transfer included 2,898 files, 174 folders and 25.572 gigs of data … FTP did not work as the server02 did not have FTP configured for root user

    • Md. Moshiur rahaman Oct 22, 2011 @ 16:21

      how to make one pc as client pc to another as aserver pc

  • Flaviana Oct 13, 2010 @ 5:34

    I want to copy emails from old server to the new server, I tried to use scp command it prompt me for password but when I put the password for my server it refused and I lost connection. Which password should I use?

  • ritsri Apr 14, 2011 @ 13:34

    scp -P port -r user@server1:/var/www/html/ user@server2:/var/www/html/

    my server 2 has also a different port so how could i defined port for server 2

  • please describe sftp with command line May 23, 2011 @ 6:32

    Please describe detailed about sftp. what should i do after this. Let’s say I want to get files ie /tmp/gds1 from server1 to server2
    I did : sftp username@server1 it prompts like
    sftp >
    what should i do from here to get file?

    please advise , it’s urgent . Also is their any tutorial clases online for this.

    Thank you

  • Automating transfer from one server to another Jan 30, 2012 @ 16:58

    I am looking to automate the transfer of back up files from an FTP account on one Linux server to another Linux Server. I don’t have admin access to either of the servers. I have tried CrossFTP with little success.

    Is it possible to script this to automate the transfer without requiring a Windows machine to act as the controller?

    Many thanks.

  • amit swarup kr. rai Apr 28, 2012 @ 10:21

    If you are serious about wanting an exact copy, you probably also want to use the -p switch to scp, if you’re using that. I’ve found that scp reads from devices, and I’ve had problems with cpio, so I personally always use tar, like this:

    cd /origin; find . -xdev -depth -not -path ./lost+found -print0 \
    | tar --create --atime-preserve=system --null --files-from=- --format=posix \
    --no-recursion --sparse | ssh targethost 'cd /target; tar --extract \
    --overwrite --preserve-permissions --sparse'

    I keep this incantation around in a file with various other means of copying files around. This one is for copying over SSH; the other ones are for copying to a compressed archive, for copying within the same computer, and for copying over an unencrypted TCP socket when SSH is too slow.

  • ram Jun 12, 2012 @ 10:59

    scp -r user@server1:/var/www/html/ user@server2:/var/www/html/
    This command is asking for password.

    • anupam yadav Sep 28, 2012 @ 6:27

      it will ask for the pasword.If ur current is server1 then you will have to provide the password of server2.

  • Ishtiaque Sep 3, 2012 @ 10:31

    I want to copy a file from one windows pc to multiple linux server at a time(same location/path). Is it possible? Current i am using Winscp for copying files. But i need to copy same file to different server individually. It is taking time. Kindly give a feedback.

  • daniel Oct 30, 2012 @ 9:39

    I have two files in remote server at same path….
    How to transfer remote server files from local server,

    Same as two files at different path ,
    pls clarify us

  • Gopi Nov 6, 2012 @ 18:37

    Thanks so much. Very useful.

  • Jegadheesh Dec 14, 2012 @ 17:04

    Thanks, It worked for me..

  • Chirag Jun 18, 2013 @ 12:44

    Thanks Alot!!!!!!!!!!!!!!!! :) :) :):) :)

  • Aamir Jul 1, 2013 @ 11:54

    I have 2 unix boxes. 1 is source and 2nd is destination. I am using a windows machine. My 2 unix boxes can not connect to each other due to security issues. Currently I copy from 1 unix box to windows and then transfer it from windows to 2nd unix box. How can I automate this process? Can I have such script to run on windows?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum