How to: Transfer files with SSH

You are recommended to store your files at CERN on centrally managed file servers (e.g. DFS on Windows, AFS on Linux). Files can then be easily accessed from both inside and outside CERN (see the recommendations on "connecting to CERN").

Below are recipes for transferring files on machines protected by CERN's firewall using SSH.

Occasional Use

Using a named LXPLUS node (e.g. for staging (maximum 30GB quota on /tmp):

$ sftp /my/local/large_file
$ ssh

On lxplusXXX:

$ sftp /tmp/large_file

Using Port Forwarding

In order to forward packets for localhost:[port] to yourmachine:22 open a terminal to initiate the port forwarding. Replace [port] by a port number greater than 1023: $ ssh -2 -N -L <port>

Open a second terminal to initiate the file transfers:

$ scp -P <port> localhost:/some/place/on/yourmachine /local/directory


$ scp -P <port> /local/file localhost:/some/directory/on/yourmachine

Multiple transfers are possible as long as the first ssh command is running.

Regular/Scripted Transfers

The command below requires no intermediate storage on LXPLUS but does require kerberos password-less authentication to be configured from lxplus to yourmachine:

 $ tar cf  /my/local/file/hierarchy | ssh ssh tar xf - -C /path/to/destination/

Or, you can use port forwarding as before:

$ ssh -L <port>
$ tar cf /my/local/file | ssh -p <port> localhost tar xf - -C /path/to/destination