如何使用 SSH (在 Windows 上使用 PuTTY)从我的服务器下载文件

当我试图从我的服务器上下载文件到我的计算机,它实际上下载到服务器上的文件。

(注意,在键入此命令之前,我已经将 SSH 连接到了服务器。我在 YouTube 上看过一些教程,人们在使用他们的终端时没有对任何特定的服务器进行 SSHing,但是我不认为我可以在 Windows 上使用 PuTTY 来做到这一点?)

scp -r -P2222 kwazy@mywebsite.example:/home2/kwazy/www/utrecht-connected.nl ~/Desktop/

问题是,我只指定了下载文件的 ~/Desktop/位置

这将在我的服务器中创建一个名为 Desktop的文件夹,而不是将文件复制到我的本地桌面上。


我可以在 Linux 上使用这个命令。

我已经成功地将文件夹下载到我的桌面上:

我仍然需要了解如何在 Windows 机器上做到这一点。

392722 次浏览

try this scp -r -P2222 kwazy@mywebsite.example:/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

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

Though PuTTY supports 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.


Even without connection-sharing, you can still use the psftp or pscp from Windows command line.
See How to use PSCP to copy file from Unix machine to Windows machine ...?

Note that the scp is OpenSSH program. It's primarily *nix program, but you can run it via Windows Subsystem for Linux or get a Windows build from Win32-OpenSSH (it is already built-in in the recent versions of Windows 10 and in Windows 11).


If you really want to download the files to a local desktop, you have to specify a target path as %USERPROFILE%\Desktop (what typically resolves to a path like C:\Users\username\Desktop).


Alternative way is to use WinSCP, a GUI SFTP/SCP client. While you browse 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.

(I'm the author of WinSCP)

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.

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

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.

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 parsa@192.168.100.11:/etc/cassandra/cassandra.yaml F:\Temporary
parsa@192.168.100.11'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)

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

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.