tags: - file transfer - sftp - Arrhenius
File transfer to/from Arrhenius using sftp¶
There are multiple ways to transfer data to/from Arrhenius.
Here, we show how to transfer files and folders using a command-line tool
called sftp,
which is a secure file transfer tool
that works under Linux, Mac and Windows.
- Copy a file from your local computer to Arrhenius
- Copy a file from Arrhenius to your local computer
- Copy a folder from your local computer to Arrhenius
- Copy a folder from Arrhenius to your local computer
Introduction¶
SFTP is an abbreviation of 'SSH File Transfer Protocol' and 'SSH' is an abbreviation of 'Secure Shell protocol'.
- The difference from
rsyncandscpis that you login to a SFTP session- just like a log in to a server with SSH.
- You use the terminal to transfer the files.
- You need the credentials only when establishing the connection.
Pros
- Secure
- Use cases:
- copying large or many files
- asks if you want to overwrite target files
- possible to resume file transfer after a broken connection.
- handle bulk file transfers
- modify directories
- and encrypt or decrypt specific files
When not to use
- Rsync is better for "syncing"
Procedure¶
- Run the
sftpcommands on YOUR computer, since you probably do not have a server address to your computer! - In the terminal (from local, not server session)
In sftp session, go to right folders and upload/download files to/from the server. You can do this as long as the connection is active!
pwd/cd/ls- browse and list files in server file systemlpwd/lcd/lls- browse and list files in local file systemput <file/folder>- Copy a file/folder from the local computer to the remote hostget <file/folder>- Copy a file/folder from the remote host to the local computer
Cheat sheet in the SFTP session
?/help- List of all commands or explain a command, e.g.? get
Remote
put- Copy a file from the local computer to the remote hostcd- Change the active directory path on the remote hostdir/ls- List the contents of the current directory on the remote hostpwd- Show the present working directory path on the remote hostmkdir- Create a directory on the remote hostrename- Rename a file on the remote hostrm- Delete a file on the remote hostrmdir- Remove an empty directory on the remote hostexit/quit- Close the connection and leave SFTP
Locally
get- Copy a file from the remote host to the local computerlcd- Change the active directory on the local systemlls- List the contents of the current directory on the local computerlmkdir- Create a directory on the local computerlpwd- Show the present working directory on the local computer
Options for compressing during the transfer
- Start the sftp session with
sftp -C <username>@<hostname> - The file(-s) are then also decompressed on the destination.
Example for Arrhenius
Connect to SFTP session
In the terminal, run sftp to connect to Arrhenius by doing:
If asked, give your center's password. You can get rid of this prompt if you have setup SSH keys
Upload/download files to/from Arrhenius
In sftp session, upload/download files/folders to/from the server.
put localfile.txt- Copy a file from the local computer to the remote hostget serverfile.txt- Copy a file from the remote host to the local computer
Source repository