How to use scp to copy a file from the server to the client side?

How to transfer files from the computer that I am accessing remotely to the computer on which I am now?

Can anybody help me?

Here is the syntax that I know so far,

scp (file name) (I don't know what to add here): (location on my computer)

+8
terminal scp command-line-arguments
source share
4 answers

If your computer is available on the Internet, this one - the hacker one, as it is - should work;

scp (filename) `echo $SSH_CLIENT | awk '{print $1}'`:(location on my computer) 

A simpler way (which will always work) is to make scp from a new window on your local computer;

 scp (remote computer):path/to/remote/file (location on my local computer) 

remote computer is the same address that you usually use ssh.

As an example, if the file is located on a remote computer called remotecomputer.com in a subdirectory of your home directory called important , and the file is called test.txt , you can send this command on the local computer to copy it to the current directory on the local computer;

 scp remotecomputer.com:important/test.txt . 
+6
source share

scp is actually easier to use than at first glance.

scp <from> <to>

<from> or <to> may be local or remote.

Deleted files look like user@host:path_on_remote

Local files are simply simple paths: /path/to/my/file.txt

If you do this manually, it may be easier for you not to copy the file back to your office computer by doing the following from the local host before entering the remote host:

scp user@remotehost:/path/to/my/file/on/remote.txt /local/path/local.txt

If you need to copy the directory - as already mentioned, you can give scp the -r option.

When you log in to the remote computer, backing up is basically the same, although you will need ssh on your local computer, which may require port porting on your local router. I usually find it easier to call scp on my laptop on the server, and not vice versa.

+8
source share

On the man page, man scp ...

scp file_on_local user@host.name:/path/to/file

If you add -r , it can make the whole directory.

0
source share

with the pem file (the pem file must be in the root directory)

 $ scp -i <pem.pem> <file_on_local> <user>@<remotehost>:/path/to/file 

with credentials

 $ scp <file_on_local> <user>@<remotehost>:/path/to/file 
0
source share

All Articles