How do I transfer files from a computer I am accessing remotely back to the computer I'm currently at?
Can anyone help me?
Here's the syntax I know so far,
scp (filename) (I don't know what to put here): (location on my computer)
How do I transfer files from a computer I am accessing remotely back to the computer I'm currently at?
Can anyone help me?
Here's the syntax I know so far,
scp (filename) (I don't know what to put here): (location on my computer)
scp is actually easier to use than appears at first glance.
scp <from> <to>
<from>
or <to>
can be local or remote.
Remote files are of the form user@host:path_on_remote
Local files are just simple paths: /path/to/my/file.txt
If you are doing this by hand, you might find it easier not to copy the file back to your office machine, by running the following from the localhost before being logged into the remote host:
scp user@remotehost:/path/to/my/file/on/remote.txt /local/path/local.txt
If you need to copy a directory - as has already been mentioned - you can give scp the -r
option.
When logged into a remote, copying back is basically the same, though you'll need ssh running on your local machine, which may require port-fowarding on your local router. I tend to find it easier calling scp
on my laptop to the server rather than the other way around.
If your computer is Internet accessible, this - hacky as it is - should work;
scp (filename) `echo $SSH_CLIENT | awk '{print $1}'`:(location on my computer)
The easier way (that will always work) is to do the scp from a new window on your local computer instead;
scp (remote computer):path/to/remote/file (location on my local computer)
remote computer
being the same address you normally ssh to.
As an example, if the file is on the remote computer called remotecomputer.com
in a subdirectory of your home directory called important
and the file is called test.txt
, you can issue this command on the local computer to copy it to the current directory on the local computer;
scp remotecomputer.com:important/test.txt .
with pem file(pem file need to located in root)
$ scp -i <pem.pem> <file_on_local> <user>@<remotehost>:/path/to/file
with credentials
$ scp <file_on_local> <user>@<remotehost>:/path/to/file