Using Scp to transfer files
The following examples should illustrate how to use scp
to
easily transfer files to and from your Duke Statistics account, depending on whether
you are:
- logged onto a remote unix host.
- To copy
myfile
from your account onremote
to your home directory at Duke Statisticsremote% scp myfile isdsmachine:
- To copy
myfile
fromremote
to thedir1
subdirectory of your Duke Statistics accountremote% scp myfile isdsmachine:dir1
- To copy
myfile
from your Duke Statistics account to your home directory onremote
remote% scp isdsmachine:myfile .
- To recursively copy
mydir
from your Duke Statistics home directory to your account onremote
remote% scp -r isdsmachine:mydir .
- To copy
- logged onto an Duke Statistics machine.
- To copy
myfile
from your Duke Statistics home directory to your account onremote
isdsmachine% scp myfile remote:
- To recursively copy
mydir
from your Duke Statistics home directory to your account onremote
isdsmachine% scp -r mydir remote:
- To copy
myfile
from your account onremote
to your Duke Statistics home directoryisdsmachine% scp remote:myfile .
- To copy
For a complete list of all the options for scp
, check out
the online man page.
Some caveats while using scp:
- If your userid (login) is different between your remote and Duke Statistics
accounts, you need to use the
userid@machine
syntax. For example, if your Duke Statistics userid is "jimbo" but your remote userid is "jtkirk":remote% scp myfile jimbo@isdsmachine: remote% scp jimbo@isdsmachine:myfile . isdsmachine% scp myfile jtkirk@remote: isdsmachine% scp jtkirk@remote:myfile .
- Wildcard characters need to be "escaped" when included in the
non-local portion of the scp command.
If you want to transfer all of the files on a remote machine that start with the letter x, you need to escape the "*".
isdsmachine% scp remote:x\* .
However, if you want to copy all of the local files starting with the letter x, you need only do the following,
isdsmachine% scp x* remote: