scp copies files between local and remote hosts over an SSH connection. Current OpenSSH uses SFTP for the transfer. These examples use placeholder usernames, hosts and paths. OpenSSH manual
Copy a remote file to this machine
scp your_username@remotehost.edu:foobar.txt /some/local/directory
Copy a local file to a remote host
scp foobar.txt your_username@remotehost.edu:/some/remote/directory
Copy a directory recursively
scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
Copy between remote hosts
scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/
Copy several local files
scp foo.txt bar.txt your_username@remotehost.edu:~
Use a different SSH port
The uppercase -P selects the port.
scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory
Copy several remote files
scp your_username@remotehost.edu:/some/remote/directory/a \
your_username@remotehost.edu:/some/remote/directory/b \
your_username@remotehost.edu:/some/remote/directory/c .
Compression is optional through -C. The current manual documents it along with cipher selection and the legacy-protocol option. This article’s former Triple-DES default claim and Blowfish examples were removed in the November 2026 review.
Thanks to Stewart Macleod for the port example.