92

When I try downloading a file from my server onto my computer, it actually downloads the file onto the server.

(Note I am already SSH'd into my server before typing this command. I've watched tutorials on YouTube and people are using their terminal without SSHing into any particular server, however I don't think I can do this with PuTTY on Windows?)

scp -r -P2222 [email protected]:/home2/kwazy/www/utrecht-connected.nl ~/Desktop/

The problem is that I am specifying the location to download the file as only ~/Desktop/

This creates a folder called Desktop in my server, instead of copying the files onto my local desktop.


I am able to use this command on Linux.

I have successfully download the folder onto my desktop:

I still need insight onto how I can do this on a Windows machine.

1

9 Answers 9

60

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

But you can use a separate SFTP/SCP client.

  • If you prefer commandline, you can use PuTTY pscp or OpenSSH scp (it's built-in in recent versions of Windows 10/11) from local Windows commandline (not from PuTTY console):

    pscp user@host:/remote/source/path/file C:\target\local\path\file
    

    The OpenSSH scp has the same syntax. Note that in recent versions the OpenSSH scp uses SFTP protocol.

  • If you prefer GUI, you can use any GUI SFTP/SCP client. For example my WinSCP.

    WinSCP integrates closely with PuTTY. While you are browsing the remote site, you can anytime open SSH terminal to the same site using 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.


Another option is use of PuTTY connection-sharing.

While you still need to run a compatible file transfer client (pscp or 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.

1
  • 5
    Short answer: Use WinSCP. Works great!
    – Josh Noe
    Commented Mar 14, 2019 at 22:29
41

try this scp -r -P2222 [email protected]:/home2/kwazy/www/utrecht-connected.nl /Desktop

Another easier option if you're going to be pulling files left and right is to just use an SFTP client like WinSCP. Then you're not typing out 100 characters every time you want to pull something, just drag and drop.

Just noticed /Desktop probably isn't where you're looking to download the file to. Should be something like C:\Users\you\Desktop

1
  • File Zilla is also a good option. Simpler than WinSCP but doesn't have all the feature
    – arjunsiva
    Commented Mar 13 at 7:21
23

OpenSSH has been added to Windows as of autumn 2018, and is included in Windows 10 and Windows Server 2019.

So you can use it in command prompt or power shell like bellow.

C:\Users\Parsa>scp [email protected]:/etc/cassandra/cassandra.yaml F:\Temporary
[email protected]'s password:
cassandra.yaml                                  100%   66KB  71.3KB/s   00:00

C:\Users\Parsa>

(I know this question is pretty old now but this can be helpful for newcomers to this question)

2
  • Note: to specify a custom port such as 123, you have to use scp -P 123 account@ipaddress ...etc. Note the uppercase P (not lower case). Commented Jun 6, 2023 at 22:57
  • @DavidGunderson Actually this is not related to Windows. In OpenSSH secure file copy implementation you must use -P for specifying port on any OS.
    – parsa2820
    Commented Jun 8, 2023 at 8:34
12

if you install git with git bash, you get SCP available on windows.

9

You can use WinSCP : https://winscp.net/eng/download.php

Or MobaXterm : https://mobaxterm.mobatek.net/download.html

It feels like FTP client. Also I don't remember setting up anything on my machine for this. It just fresh install and install SSH server (IDK if it matters though). enter image description here

enter image description here

For MobaXterm :

enter image description here

7

If your server have a http service you can compress your directory and download the compressed file.

Compress:

tar -zcvf archive-name.tar.gz -C directory-name .

Download throught your browser:

http://the-server-ip/archive-name.tar.gz

If you don't have direct access to the server ip, do a ssh tunnel throught putty, and forward the 80 port in some local port, and you can download the file.

3

You can use the WinSPC program. Its access to any server is pretty easy. The program gives its guide too. I hope it's helpfull.

3
  • 1
    Welcome to Stack Overflow! Can you elaborate more in your answer? For example, can you give an example how to use the WinSPC program?
    – L. F.
    Commented Feb 1, 2019 at 0:23
  • Considering that you already have archives in your server (that you access using PuttY, right?) so you construct the following code: spc <folder of your archive on the serv> <name of the server>:<folder of paste>. You already know this. So now you download and open the winSPC and when it starts, you can log your server in there. After this you can access the folder and select download. It's pretty easy. If you still have question, search on google about the program, or download its handbook.I hope it's helpfull.
    – Luan Souza
    Commented Mar 30, 2019 at 6:48
  • @LuanSouza Possible typo for WinSCP?
    – site80443
    Commented May 10, 2021 at 11:40
1

If you need something with GUI you can use FileZilla. it support SFTP.

It's perfectly working with ssh and you can even edit files and it will automatically upload the changes.

-1

You can do this on your terminal

scp root@{ip of server}:/root/{file name}.{file extension} <directory path you want your remote file to be downloaded at>

Not the answer you're looking for? Browse other questions tagged or ask your own question.