# How do I transfer a file to my server using PuTTY?

when calling SCP in PuTTY on my Win7 box, it doesn't let me use C:/, but I also have no idea where on my local machine it will look for files by default. None of program directory or user directory worked. For example, I saved file.txt next to PuTTY.exe, and also in C:\Users\Me but calling SCP file.txt file.txt in PuTTY failed both times with

cp: cannot stat 'file.txt'

So, how do I transfer a file to my server using PuTTY?

EDIT: Also, calling SCP file.txt myserver:file.txt gives a similar error: file.txt: No such file or directory

-

## migrated from stackoverflow.comSep 21 '11 at 8:07

This question came from our site for professional and enthusiast programmers.

do you know the full path to your file.txt? do SCP full-path-to-file.txt myserver:file.txt –  Shadow_boi Sep 21 '11 at 3:43
Thanks shadow_boi, but that's the problem: using full path means including c:\, which gives me the error ssh: Could not resolve hostname c: Name or service not known –  Trindaz Sep 21 '11 at 3:47
I guess you loged into the server using putty and typed in the CP comment as you mentioned above? That is the issue. Now you are at the server, so when you type C: the server doesn't have c drive –  Shadow_boi Sep 21 '11 at 4:26
I dont think putty alone can do the job. WinSCP is a nice GUI tool for secure copy of files, Putty works very well for the job also using the command line tool called pscp. –  Shadow_boi Sep 21 '11 at 4:28
I had the issue of using pscp to copy a file through an intermediate server. This question was the base of me figuring out. The full instructions on taking this question to the next step are here superuser.com/q/577663/57649 –  Scott Apr 7 '13 at 20:45

Have you tried something like

pscp -l user1 c:\ftp\picture.jpg slacker1:/home/user1/pics


The manual for Putty suggests

To send (a) file(s) to a remote server:

pscp [options] source [source...] [user@]host:target

So to copy the local file c:\documents\foo.txt to the server example.com as user fred to the file /tmp/foo you would type:

pscp c:\documents\foo.txt fred@example.com:/tmp/foo

Postscript

The Putty download page lets you download putty.zip - a complete set of Putty tools or you can just download the tools you need (in which case you might have downloaded putty.exe but not yet have downloaded pscp.exe)

-
I have putty installed. I dont seem to have pscp available either within the putty shell or within my local shell. Could you shed a bit more light? Where do you run pscp from? Cheers –  Jonny Leeds May 1 '14 at 13:17
@JonnyLeeds: I run it in a Windows command prompt (cmd) from the Putty installation directory e.g. C:\Program Files (x86)\PuTTY\pscp.exe in my case. You can either put the full path in double quotes (because of the spaces in it) or add the directory to your %PATH% (see other answers here for how to do that). –  RedGrittyBrick Jan 6 at 16:04
Hi thanks for the response but all I have in my putty folder is putty.exe, puttygen.exe and a ppk file –  Jonny Leeds Jan 21 at 14:58
@JonnyLeeds: You can either download just pscp.exe from chiark.greenend.org.uk/~sgtatham/putty/download.html or download a putty.zip containing a complete, consistent set of the latest version of Putty tools and replace the sparse set you have. –  RedGrittyBrick Jan 21 at 16:45
Great answer. One more tidbit: you can often use a period after the remote location's colon if you don't know where you want the file to go. For instance: pscp -l username C:\dir\file.txt server:. –  TOOGAM Jan 28 at 3:22

A solution that doesn't use PuTTY: Connect to server with FileZilla using SFTP to transfer files.

-

I couldn't find pscp as suggested above and ended up using WinScp.

It's a client side program with a GUI which picks up your putty configs.

-
chiark.greenend.org.uk/~sgtatham/putty/download.html offers pscp.exe and the similar psftp.exe file. The the.earth.li/~sgtatham/putty/latest/x86/… (for version 0.63, which is the latest version at the time of this writing) may be simplest for people who prefer being walked through an easy installation process using a GUI, while the putty.zip file also contains putty.exe and pscp.exe and psftp.exe –  TOOGAM Jan 28 at 3:26

this worked for me From cmd set PATH=C:\path\to\putty\directory;

http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html

-
You should add more details in your post that will support your answer to this question rather than simply posting a link. –  Renju Chandran chingath Jan 28 at 4:32