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

2) Install Putty on Windows machine: PuTTY is a free implementation of Telnet and SSH for Windows and Unix platforms. Note: find the "Windows Installer for Everything" and install on windows: https://putty.org/

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.

putty1

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

putty2

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:

putty3

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.

You have no rights to post comments