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. lxplusXXX.cern.ch) for staging (maximum 30GB quota on /tmp):

$ sftp /my/local/large_file lxplusXXX.cern.ch:/tmp/
$ ssh lxplusXXX.cern.ch

On lxplusXXX:

$ sftp /tmp/large_file yourmachine.cern.ch:/path/to/destination/

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>:yourmachine.cern.ch:22 lxplus.cern.ch

Open a second terminal to initiate the file transfers:

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

or

$ 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 lxplus.cern.ch ssh yourmachine.cern.ch tar xf - -C /path/to/destination/

Or, you can use port forwarding as before:

$ ssh -L <port>:yourmachine.cern.ch:22 lxplus.cern.ch
$ tar cf /my/local/file | ssh -p <port> localhost tar xf - -C /path/to/destination