Remote Systems

Transfer Files

Learning Objectives

  • Learn to transfer files from/to remote systems using scp

Data Download

Transfer a single file

$ scp notes.text spruce.hpc.wvu.edu:transfered.txt
notes.txt                       100%   86     0.1KB/s   00:00

Transfer a directory

$ scp -r molecules spruce.hpc.wvu.edu:.
cubane.pdb                           100% 1158     1.1KB/s   00:00    
ethane.pdb                           100%  622     0.6KB/s   00:00    
methane.pdb                          100%  422     0.4KB/s   00:00    
octane.pdb                           100% 1828     1.8KB/s   00:00    
pentane.pdb                          100% 1226     1.2KB/s   00:00    
propane.pdb                          100%  825     0.8KB/s   00:00

A better way might be to copy the entire zip file

$ scp shell-novice.zip spruce.hpc.wvu.edu:

We can check that the files are on the remote system

$ ssh spruce.hpc.wvu.edu ls
molecules
shell-novice-data.zip
special.txt

Reverse the order of hostname and filename to download the file from the remote system.

$ scp mountaineer.hpc.wvu.edu:special.txt download.txt
$ ls
download.txt

======= > * Retrieve/put files from/to remote systems using sftp > * Retrieve/put files from/to remote systems using scp

Connect using sftp

$ sftp spruce.hpc.wvu.edu

list remote directory

sftp> ls

list local directory

sftp> lls

change remote directory

sftp> cd

change local directory

sftp> lcd

download file

sftp> get

put file

sftp> put

Use the -R flag for directories

sftp> put -R

sftp has a list of other commands mirror filesystem commands

sftp> help

exit sftp

sftp> exit

Simplifying transfers with SCP

transfer a single file

$ scp localfile spruce.hpc.wvu.edu:remotefile

retrieve a file

$ scp spruce.hpc.wvu.edu:remotefile localfile

Use the -R flag for directories

$ scp -r spruce.hpc.wvu.edu:remotedir localdir