skip to primary navigationskip to content
 

SCP

SCP clients

SCP clients are available on most Unix systems including MCS Linux, and as part of the underlying Unix system on a Macintosh running OS X. On the MCS Windows PCs a graphical SCP client, WinSCP, is available and there is also a basic line-mode client pscp.

The basic SCP command carries out a single file transfer (unlike SFTP or FTP where, once connected, you can carry out any number of transfers). More complicated operations can be carried out using the ssh command, as described below.

Using the scp command on a Unix system

The simplest type of scp call carries out a single file transfer.

If you are using MCS Linux, for instance, to transfer a file called test from DS-Filestore to Hermes without changing its name, the basic command is

  • scp test hermes:

You will be asked to supply your Hermes password before the transfer is made.

To fetch the same file back and change its name to test1, use

  • scp hermes:test test1

You can transfer a whole directory using the -r option:

  • scp -r mydir hermes:

Users familiar with the ssh protocols will be able to avoid the password prompts by using pure RSA authentication. The RSA public keys can be put in the file ~/.ssh/authorized_keys in the ordinary way. Users of RSA authentication must take great care not to expose their private keys.

The scp command only copies files or directories; it does not easily allow you to list your files on the remote host, or delete, copy or rename them. To do any of these interactively, you need to login to the host (typically using the ssh command) and use whatever file management commands are available to you at the host end. Hermes, for instance, makes limited file management operations available through its menu system. Other Unix hosts such as MCS Linux give you access to the full range of Unix file commands.

You can also add commands to the ssh line itself rather than logging in, e.g., you can list your Hermes files using

  • ssh hermes ls

or delete a DS-Filestore file using

  • ssh linux.ds rm myfile

To list your Word documents stored in your DS filespace, use

  • ssh linux.ds ls '*.doc'

(note that the name *.doc is in quotation marks so that the * will not be expanded on the client machine, but passed unchanged to the filestore for expansion there.)

To find your quota on DS-Filestore, use

  • ssh linux.ds quota -v

You can also put several commands in a file, and obey them in sequence, using

  • ssh hermes <myfile

It is also possible to carry out file copying non-interactively using ssh rather than scp, so users who are confident with various aspects of Unix can use the cat command and its variants to combine packing and compressing files with sending the result to a remote system, or the reverse process. For example, the following command issued on a client Unix machine will create, on the remote system, a compressed tar archive of a directory on the client machine:

  • (cd mydir && tar cvf - .) | compress | ssh hostname cat2 mydir.tar.Z

and the following command issued on a client Unix machine will fetch and unpack a compressed tar archive:

  • ssh hostname cat mydir.tar.Z | zcat | (cd mydir && tar xvf -)

Using WinSCP

WinSCP is a Windows interface to SCP available on the MCS Windows PCs (see https://winscp.net/eng/index.php for obtaining your own copy). Note that it works with the DS-Filestore sftp server, if you operate it in sftp mode.

Start WinSCP from the Start menu (click on Start, point to All ProgramsNetwork Tools, then click on WinSCP). You should then see a box listing "stored sessions". Either select one of these and click Load, or to connect to any other host click on the Basic tab. Fill in the hostname if needed, and your username and password on the remote system. Select scp or sftp mode, then click on Login.

Once the connection has been made, two panels are displayed: one for your local system and one for the remote system. Each panel includes a pull-down menu for switching between directories or devices, and a button for moving up to the parent directory. You can click on any folder within the panel to open it.

You can drag and drop files between the two panels (you may not see something you have just moved in the listing until you select Refresh from the Local or Remote menu as appropriate).

Alternatively, the buttons listed along the bottom of the panel allow you to move the selected file or files from one system to the other, and also to carry out many of the operations (such as deleting and renaming files and creating directories on the remote system) not available in other SCP clients.

WinSCP provides a choice of interfaces; one as above, which is selected by default on the Managed Cluster Service, and the other looking like Windows Explorer. The choice between interfaces is made via the Preferences item on the Options menu.

Using pscp (PC)

This is a line-mode program and looks very much like the Unix scp command (see earlier section), so the details are not repeated here.

To launch pscp, you need to call up a Command Prompt window (click on Start, move to Programs, then Accessories, and click on Command prompt). The command syntax is then roughly as for Unix scp, except that by default you have to give your user identifier before the hostname, e.g.

  • pscp filename spqr1@linux.pwf:newfilename

It may be useful to know that in Windows, if you drag a file into a command prompt box, the name of the file will be added to the current command.