Info Services > Computing Guide > Network Access > SSH Pages > Secure Copy (SCP) File Transfer

Secure Copy (SCP) File Transfer

Secure Shell, File Transfer, FTP, SFTP, Remote Access, OpenSSH, RCP,

NRAO Employees: Network access is for use on NRAO-approved machines only. Complete the Permission to Connect non-NRAO Computer to NRAO Network form (PDF) and have it authorized by your local computing division head before attempting any connections except "nraoPUBLIC". Please note that VPN is the preferred remote connection technology.

Visitors: May make use of NRAO public wireless networks where available. For RFI restricted areas, contact the Help Desk.


Quick Roundup - What is SCP?

It copies files from one computer to another over the net.

If you think ftp is the only way to move files around the internet, or our intranet, you are mistaken. The secure copy command allows you to copy local files to a remote system, or vice versa. It can handle copying whole directory trees just as well as a single file. Over slow links, you can have it compress the data stream. And best of all, the file is transmitted in an encrypted manner; nobody can "snoop" either on a password you might type in to enable a copy operation, or on the data in transit.

scp is part of the ssh (Secure Shell) Package. On our Linux systems, the OpenSSH package comes as part of the system. On Windows systems, we either install SecureCRT (which has an equivalent VCP command, or for your own private systems we recommend that you get putty which has "scopy" functionality.

scp is the secure equivalent of rcp (one of the older Berkeley "r" or remote commands). Its syntax is very much the same as rcp, so if you were used to using that tool, using scp should be easy.


How do I use SCP?

These examples assume you are logged into polaris.

Copy a local file from polaris to sadira
scp myfile.wpd sadira:

The file myfile.wpd in the current directory on polaris will be copied to your login area on sadira.


Copy a remote file from a subdirectory on zia to polaris
scp zia:data/fits/3c273.fits ./fits/orig_3c273.fits

The file 3c273.fits in your data/fits/ subdirectory on zia (relative to your login area there) is copied to a subdirectory fits/ relative to the current directory on polaris, and takes on a new file name.


Copy a remote file on sadira to a remote file on zia
scp sadira:/home/aips/FITS/rotten.data
        zia:/AIPS/FITS/

This will copy the file /home/aips/FITS/rotten.data on sadira to a file of the same name in the /AIPS/FITS/ directory on zia.

Note: Remote Paths are relative to your login area unless begun with a "/".



More Advanced Use of SCP

Multiple Files, Wild Cards

      • scp *.ps sadira:tmp/
        This will copy all files matching *.ps in the current directory to your ~/tmp/ directory on remote host sadira.

         

      • scp zia:public_html/paper3.html sadira:fig.jpg ./html/
        This copies a file in your ~/public_html/ directory on zia, and a file in your login area on sadira to a local subdirectory called html/ relative to your current working directory. The last item in a scp command is always the destination.

         

Recursive Copying (whole directories)

      • scp -r ./mydir zia:work/temp/

Different Account Names

      • scp myfile.txt myacct@example.edu:tmp/

Compression

      • scp -C sadira:work/papers/*.ps ./papers/backups/

        (Files are compressed only in transit; with fast machines on each end, and nicely compressible [text, PS] files, this can cut copying time significantly).

Setup

      • See the Login/Bastion Servers section of the SSH Guide  to set up your ssh key (and avoid entering your password for every scp command).

SCP vs. FTP

Pros:

          • More convenient: no need to "log on" to remote side(s)
          • More versatile: Can gather files from several machines at once
          • More secure: password never travels "in the clear"

Cons:

          • It's different (devil you know...)
          • May not have sshd running on outside hosts (changing fast)
          • Does not allow anonymous access (use the web instead)

Conclusions

      • scp is a viable and useful modern alternative to ftp and rcp.
      • It offers some increased security (against password sniffers).
      • However, It's only as secure as the end points (source, destination machines).
Permission Form for Non-NRAO Computers
Info Services Contacts