Copying Files Between Remote Servers

interactively, using the command line

This is a note-to-self because I only have to do this rarely and every time I do I have to remind myself.

SFTP

sftp is what you want to use. There are other options like rsync or whatever and if you’re writing a backup script or something that’s probably a better choice but if you’re not sure where things are and you want to cd around both the local and remotes before copying, sftp works well.

# This will start a new SFTP session which give you a `sftp>` prompt
sftp username@some-server

# View the remote directory
sftp> ls

# View your local directory (the extra l means local)
sftp> lls

# Transfer foo.txt from your local directory to the remote directory
sftp> put foo.txt

# Transfer bar.zip from the remote directory to your local directory
sftp> get bar.zip

# Show all available sftp commands
sftp> help
Created
June 2026
Tags
#blog