Transferring Files on Fox

Access to the compute and storage systems on Fox is permitted only through secure shell (ssh).

One can use scp (secure copy), sftp (secure file transfer protocol), or rsync to upload or download data. There is a graphical frontend for scp on Windows called WinSCP.

Transferring files on Mac OSX and Linux can be done in the command prompt. To copy files from one computer to another via the command line, we recommend scp. More advanced users may prefer rsync.

scp: secure copy (command line)

scp copies files between machines using the ssh protocol for data transfer.

The basic syntax to copy a file from a source location to a destination is:
scp [user@]host:[source path] [user@]host:[destination path]

A few typical examples when using scp:

# copy a single file to home folder on Fox
# note that the destination folder is omitted, with the home folder being the default:
$ scp my_file.tar.gz <username>@fox.educloud.no:

# the -r option is used to copy an entire directory:
$ scp -r my_dir/ <username>@fox.educloud.no:/cluster/work/users/<username>/

# copy a result directory back to my laptop
$ scp -r <username>@fox.educloud.no:/cluster/work/users/<username>/my_results /home/some/place

Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing : as host specifiers.

Example:

# trying to copy a file containing a colon like so:
$ scp myfile:version1 <username>@fox.educloud.no:

# will result in:
$ ssh: Could not resolve hostname myfile: nodename nor servname provided, or not known

# instead use:
$ scp ./myfile:version1 <username>@fox.educloud.no

sftp: secure file transfer protocol (command line)

sftp is an interactive file transfer program which also contains file management commands.

In this example we copy all logs with names that start with “out” and end with “.log” from the project1 folder to /fox/projects/project1, then retrieve files from /fox/projects/project2:

# start sftp on the destination server:
$ sftp <username>@fox.educloud.no

sftp> lcd project1
sftp> cd /fox/projects/project1
sftp> put out*.log
sftp> get /fox/projects/project2

As always, additional options and examples may be found in the man pages by typing man scp or man sftp.


CC Attribution: This page is maintained by the University of Oslo IT FFU-BT group. It has either been modified from, or is a derivative of, "File transfer" by NRIS under CC-BY-4.0. Changes: Added additional information to code examples.