tel: +2348055401551 (sms, whatsapp)
skype: tokunboajewole

How to transfer files between Linux and Windows using Putty

This tutorial explains how to transfer files between a Windows PC and a Linux Server using Putty. The Linux distribution / test-box used is Debian-7 wheezy; the Windows test-PC runs Windows XP professional.

1) Setup your Linux sever for SSH access if you haven't done so already. Click below tutorial link and refer to section#1: update Debian-7 and install OpenSSH SSHD server

Tutorial: how to install SSH and VNC server for remote desktop access in Debian-7 Wheezy

2) Install Putty on Windows machine: PuTTY is a free implementation of Telnet and SSH for Windows and Unix platforms. Download Putty from here: click here to download putty. Note: find the "Windows Installer for Everything" and install on windows.

The Putty-GUI can be used to SSH-connect to your Linux Box, but for file- transfer, we just need one of the putty tools called PSCP. File transfer from Windows to Linux is achieved via DOS Command prompt.

fig3

 

3) With Putty installed, set Putty's path so that PSCP can be called from DOS command line:

fig2

Click above image to enlarge. Note that Putty is installed with default settings (in C-drive). If you install Putty in some other DIR, please modify the below commands accordingly:

Now on Windows DOS command prompt:

a) set the path from Windows Dos command line(windows):

type this command: set PATH=C:\Program Files\PuTTY

b) check / verify if PSCP is working from DOS command prompt:

type this command: pscp

If all is well, you should get a result as below:

fig1

 

4) File transfer examples: the following are some examples, but please, note that:

  • sample-dir in linux-box: /home/tokunbo
  • sample-dir in windows-box: c:\temp

a) Copy a file from Linux to windows : I want to copy a file named LinuxtoWindowsfile.txt from Linux to Windows, the copy-command format is like this:

command format:
pscp.exe linux-username@linux-server-ipaddress: [source-DIR-inLinux] [destination-DIR-inWin]

example:
pscp.exe tokunbo@my-ipaddress:/home/tokunbo/LinuxtoWindowsfile.txt c:\temp

note: in the above, the file to be copied resides in my Linux home-dir: /home/tokunbo; and I am copying to Windows c:\temp

b) Copy several files from Linux to Windows:

example:
pscp.exe tokunbo@my-ipaddress:/home/tokunbo/testfiles/*.txt c:\temp\bulk

where: "testfiles" is the DIR containing the files I need to copy, and "bulk" is the DIR where I want all the files to be copied to.

If all the files in a DIR are needed, its simpler to compress the entire DIR and copy as a single file.

c) Copy a file from Windows to Linux: to copy files from Windows to Linux, the pscp command just has to be reversed. For example, we have a file sunset.jpeg in c:\temp on Windows to be copied to Linux.

command format:
pscp.exe [source-DIR-inWin] linux-username@linux-server-ipaddress:[destination-DIR-inLinux]

example:
pscp.exe c:\temp\sunset.jpg tokunbo@my-ipaddress:/home/tokunbo

The same applies if several files are to be copied:

d) Copy several files from Windows to Linux:

example:
pscp.exe c:\temp\bulk\*.jpg tokunbo@my-ipaddress:/home/tokunbo

where "bulk" contains all the jpeg-files to be copied.


Note: pscp has several options which make file-admin really cool. Besides it has the ftp-protocol. See putty/pscp help file / website for more info.

 

Related tutorials:

Comments   

 
+1 #3 Alaa 2016-06-26 08:30
Very useful article.

Thanks a lot!
Quote
 
 
+1 #2 Tim 2016-05-17 14:15
Sir thank you very much :D works like a charm.
Currently using it between Raspbian Jessie and Windows 10 :)
Quote
 
 
+1 #1 AR 2015-10-06 18:58
im getting an error "pscp is not recognized as an internal or external command..."
Quote
 

Add comment


Security code
Refresh

I use Linux 24x7

Recent Comments