Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download a file from my server using SSH (using PuTTY on Windows)

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'd greatly appreciate any assistance.


Update:

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.

like image 762
SobieSki Avatar asked Mar 02 '14 11:03

SobieSki


People also ask

How do I download files from PuTTY to Windows?

To get files you use a related program, pscp.exe, included with PuTTY. Run the pscp.exe executable on the Windows command line to quickly copy files from a remote PC to the local computer hard drive.

How do I download a file from server using SSH?

Scp Command The "scp" command is a secure version of the Unix copy command "cp." Once you establish an SSH session with the remote machine, locate the file you wish to copy. The "scp" command is a better option if you have only a few files to transfer. The "-p" flag preserved the file modification and access times.


1 Answers

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 latest versions of Windows 10).


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)

like image 69
Martin Prikryl Avatar answered Oct 02 '22 22:10

Martin Prikryl