How do I copy a file from a local machine to a 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

asked Sep 21, 2011 at 3:34

2

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 :/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)

answered Sep 21, 2011 at 9:08

How do I copy a file from a local machine to a server using PuTTY?

RedGrittyBrickRedGrittyBrick

80.3k19 gold badges132 silver badges199 bronze badges

5

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

answered Sep 21, 2011 at 4:30

TrindazTrindaz

6151 gold badge5 silver badges12 bronze badges

There's no way to initiate a file transfer back to/from local Windows from a SSH session opened in PuTTY window.

Though the recent versions of PuTTY support connection-sharing.

While you still need to run a compatible file transfer client (the pscp or the psftp), no new login is required, it automatically (if enabled) makes use of an existing PuTTY session.

To enable the sharing see:
Sharing an SSH connection between PuTTY tools.


Alternative way, is to use WinSCP, a GUI SFTP/SCP client. While you browse the remote site, you can anytime open an SSH terminal to the same site using the Open in PuTTY command.

See Opening Session in PuTTY.

With an additional setup, you can even make PuTTY automatically navigate to the same directory you are browsing with WinSCP.

See Opening PuTTY in the Same Directory.

(I'm the author of WinSCP)

answered Apr 13, 2015 at 6:39

Martin PrikrylMartin Prikryl

20.1k9 gold badges71 silver badges152 bronze badges

0

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.

answered May 1, 2014 at 13:25

JonnyRaaJonnyRaa

2031 gold badge3 silver badges10 bronze badges

1

  1. In PSFTP open the folder you want to put the file in.
    Ex. cd filename
  2. In the command line type: lcd pathtofolder
    Ex. lcd C:\Users\Lyn\Pictures
  3. Click enter and type: put filename
    Ex. put lynhw1.pdf
  4. Click enter and the file should be transferred

Hope it works for you as it does for me.
Note: I did this in PSFTP using Putty.

"PSFTP, the PuTTY SFTP client, is a tool for transferring files securely between computers using an SSH connection" - http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter6.html

Download PSFTP on the http://www.putty.org/ webpage. Under download putty here.

answered Feb 8, 2017 at 23:41

1

If you want to automate this kind of file transfer via .bat:

@echo off

set pw=foobemcfoobar

set inp=input.lst

for /F "tokens=*" %%i in (%inp%) do (

echo %%i

echo y | C:\tmp\pscp.exe -C -agent -pw "%pw%" C:\tmp\files\foo.txt root@%%i:/tmp/

echo "=== Accepting SSH, copying ...==="

 )

(where input.lst is a text file with targets listed)

How do I copy a file from a local machine to a server using PuTTY?

bertieb

7,21436 gold badges40 silver badges52 bronze badges

answered Mar 20, 2018 at 14:04

3