SCP Cheatsheet


Copy local file to a remote host

scp request.csv armann@
reqquest.csv needs to be in your current directory.

Copy a file from a remote host

scp armann@ .
The dot at the end represents your current local directory.

Copy local folder to a remote server

scp -r /home/armann/Music/ armann@

Copy a remote folder

scp -r armann@ /home/armann/

Copy a file from a remote server to a remote server

scp armann@

SCP Flags/Options

–r Recursively copy entire directories. Note that this follows symbolic links encountered in the tree traversal.

-C Compression enable. Passes the -C flag to ssh to enable compression.

-l Limits the used bandwidth, specified in Kbit/s.

-o Can be used to pass options to ssh in the format used in ssh_config.

-P Specifies the port to connect to on the remote host. Note that this option is written with a capital ‘P.’

-p Preserves modification times, access times, and modes from the original file.

-q Disables the progress meter as well as warning and diagnostic messages from ssh.

-v Verbose mode. Print debugging messages about progress. This is helpful in debugging connection, authentication, and configuration problems.


“Too many authentication failures”

Most likely you have five or more ssh keys loaded. Check how many keys you have with ssh-add -l

If you see five keys or more you are out of luck for now. Remove one of the keys you are not going to be needing soon.

ssh-add -L ~/.ssh/id_ed25519yourprivatekey

If that doesn’t work you can remove keys with ssh-add -D

Your ssh client will attempt to use all the keys from ssh-agent one by one before it gets to use the key you specified with -i. Each attempt counts as an authentication failure and by default only 5 attempts are allowed by the SSH server you are getting the error you see. Too many authentication failures.

“Could not open a connection to your authentication agent“

eval $(ssh-agent) ssh-add <private-key>

Here you’re starting the ssh-agent. This initializes the “SSH_AUTH_SOCK” environment variable which is used by the other SSH tools to find the Unix socket for the agent.

How to SCP data