scp Linux Command
Securely copies files between local and remote hosts over SSH.
What does scp do?
Securely copies files between local and remote hosts over SSH.
Syntax
scp [options] source destinationPractical example
scp file.txt kali@remote:/home/kali/Questions about scp
How do I copy a file to a remote server?
Use `scp file.txt user@remote:/path/` to copy a file from your local machine to the remote server.
How do I copy a file from a remote server?
Use `scp user@remote:/path/file.txt /local/path/` to copy a file from the remote server to your local machine.
How do I copy a directory with scp?
Use `scp -r /local/dir user@remote:/path/` to recursively copy a directory and all its contents.
How do I use a non-standard SSH port with scp?
Use `scp -P 2222 file.txt user@remote:/path/` to specify port 2222. Note the uppercase -P.
How do I preserve file permissions with scp?
Use `scp -p file.txt user@remote:/path/` to preserve modification times, access times, and permissions.
How do I copy between two remote servers?
Use `scp user1@host1:/path/file user2@host2:/path/` to copy directly between two remote machines.
How do I limit bandwidth with scp?
Use `scp -l 1000 file.txt user@remote:/path/` to limit bandwidth to 1000 Kbit/s.
What is the difference between scp and rsync?
scp copies files once. rsync can sync directories, resume interrupted transfers, and only transfer changed parts of files.
Related Remote Access Commands
sshConnects securely to a remote machine via the SSH protocol.
rsyncEfficiently syncs files and directories between two locations (local or remote).
ssh-copy-idCopies your SSH public key to a remote server for key-based authentication.
ftpTransfers files to and from a remote host using the File Transfer Protocol.
ssh-keygenGenerates SSH public/private key pairs for passwordless authentication.
sftpSecurely transfers files over SSH (interactive FTP-like interface).