Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a file from remote server to local machine? [closed]

Tags:

linux

scp

cp

ubuntu

In my terminal shell, I ssh'ed into a remote server, and I cd to the directory I want. Now in this directory, there is a file called table that I want to copy to my local machine /home/me/Desktop. How can I do this?

I tried scp table /home/me/Desktop but it gave an error about no such file or directory. Does anyone know how to do this?

Thanks

like image 389
omega Avatar asked Mar 05 '15 02:03

omega


People also ask

Can you transfer a file from the remote machine to the local machine?

Copy and paste the required file from the remote machine in the cloud storage disk. Now, the file will appear in the file transfer window as shown below. Click the download icon against the file. Now the file will be downloaded to your local machine.

How do I SCP to a local machine?

SCP syntax is pretty simple. Just invoke SCP followed by the remote username, @, the IP address or host, colon, and the path to the file. If not specified, the default path is the remote user's home directory. Then, define the local path where the file will be stored locally.

How do I fetch a file from a remote server?

The scp command issued from the system where /home/me/Desktop resides is followed by the userid for the account on the remote server. You then add a ":" followed by the directory path and file name on the remote server, e.g., /somedir/table. Then add a space and the location to which you want to copy the file.


2 Answers

For example, your remote host is example.com and remote login name is user1:

scp [email protected]:/path/to/file /path/to/store/file 
like image 51
kkpoon Avatar answered Oct 06 '22 01:10

kkpoon


The scp operation is separate from your ssh login. You will need to issue an ssh command similar to the following one assuming jdoe is account with which you log into the remote system and that the remote system is example.com:

scp [email protected]:/somedir/table /home/me/Desktop/. 

The scp command issued from the system where /home/me/Desktop resides is followed by the userid for the account on the remote server. You then add a ":" followed by the directory path and file name on the remote server, e.g., /somedir/table. Then add a space and the location to which you want to copy the file. If you want the file to have the same name on the client system, you can indicate that with a period, i.e. "." at the end of the directory path; if you want a different name you could use /home/me/Desktop/newname, instead. If you were using a nonstandard port for SSH connections, you would need to specify that port with a "-P n" (capital P), where "n" is the port number. The standard port is 22 and if you aren't specifying it for the SSH connection then you won't need that.

like image 34
MoonPoint Avatar answered Oct 06 '22 01:10

MoonPoint