How do I download a file from server to local machine SSH?

It depends on what your local OS is.

If your local OS is Unix-like, then try:

scp username@remoteHost:/remote/dir/file.txt /local/dir/

If your local OS is Windows ,then you should use pscp.exe utility. For example, below command will download file.txt from remote to D: disk of local machine.

pscp.exe username@remoteHost:/remote/dir/file.txt d:\

It seems your Local OS is Unix, so try the former one.


For those who don't know what pscp.exe is and don't know where it is, you can always go to putty official website to download it. And then open a CMD prompt, go to the pscp.exe directory where you put it. Then execute the command as provided above

EDIT

if you are using Windows OS above Windows 10, then you can use scp directly from its terminal, just like how Unix-like OS does. Thanks to @gijswijs @jaunt @icanfathom

How do I download a file from server to local machine SSH?
Users can securely download a file from any remote server with SSH by using the scp tool at the command line. Essentially this means you can have a file stored securely on a remote server and transfer it to local storage without having to expose that file to the outside world, because scp offers the same level of security and requires the same authentication that ssh does.


Securely downloading files with scp is aimed primarily at advanced users who are using ssh and the command line regularly in either macOS X, bsd, or linux. For those with adequate command line experience, using ssh and scp to download remote files is easy and, conveniently, after the file transfer has completed, the remote connection will end. This makes scp preferential to sftp for quick file downloads, though you could obviously use sftp if you wanted to as well.

Downloading a File from Remote Server with SSH Secure Copy

This assumes the remote server has ssh active, and if you’re able to ssh into the machine then it will have likely have scp active as well. If you don’t have a remote server to try this with, you can try it out between Mac OS X machines or with localhost if you enable ssh and Remote Login on the Mac beforehand.

The basic syntax to use scp (secure copy) for securely downloading remote files is as follows, replacing user, server, path, and target as appropriate:

scp user@server:/path/to/remotefile.zip /Local/Target/Destination

For example, to download a file to the local desktop named “filename.zip” located in the home directory of remote user “osxdaily” on server IP 192.168.0.45, the syntax would be as follows:

% scp :filename.zip ~/Desktop/
Password:
filename.zip 100% 126 10.1KB/s 00:00
%

Assuming authentication is correct, the target file will immediately start to download to the target destination, offering a percentage completion, download speed, and elapsed transfer time as the file download proceeds.

As usual with the command line, it’s important to specify exact syntax.

If the file or path has a space in the name, you can use quotations or escaping on the path like so:

scp :"/some remote directory/filename.zip" ~/Desktop/

scp can also be used to securely place a file on a remote server by adjusting the syntax as well, but we’re focusing on downloading a file rather than uploading files here.

If you’re new to ssh and testing this out yourself, and if you have never connected to the remote server before, you will be asked to confirm whether or not you wish to actually connect to the remote machine. This looks like so, and requires a ‘yes’ or ‘no’ answer before the download begins.
% scp :filename.zip ~/Desktop/
The authenticity of host '192.168.0.4 (192.168.0.4)' can't be established.
ECDSA key fingerprint is SHA256:31WalRuSLR83HALK83AKJSAkj972JJA878NJHAH3780.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.4' (ECDSA) to the list of known hosts.
Password:
filename.zip 100% 126 0.1KB/s 00:00
%

Again, assuming the connection is approve and the login is successful, the remote file will download from the target server to the localhost.

You can also use scp to download multiple files from a remote server:

scp user@host:/remote/path/\{file1.zip,file2.zip\} /Local/Path/

Using ssh for remote file downloads like this is most appropriate for secure transfers which require authentication. Sure you can also downloading files with curl or wget from remote servers, but files accessible with curl and wget tend to be accessible from the outside world as well, whereas ssh and scp requires authentication or a key, and uses 3DES encryption, making it considerably more secure.

Can you download files through SSH?

It's based on the SSH protocol used with it. A client can use an SCP to upload files to a remote server safely, download files, or even transfer files via SSH across remote servers.

How do I download a file from a remote server to a local machine?

To copy the files you will need to first invoke the SCP, followed by the remote username@IP address, path to file. If you do not specify the path, it is assumed as default in this case which will be the user's home directory, this will be followed the path where the file will be stored locally.

How do I download and upload files using SSH?

Upload file using SSH You can also upload files to the remote server using SSH protocol using the SCP command. Use the following example command for uploading files to the SSH server. Similarity you can use -P switch to define port of the SSH server and -i to define private key for the user authentication.

How do I transfer files from Linux server to local machine?

To download files from the Linux server to your computer, you need to provide SCP with the local path of the file or directory and the path on the Linux Server where you'd want your file to be uploaded. After running this command, it will require the authentication password of the linux server.