Igor Khromov blog

Cheat sheet for ‘scp’ terminal command

Cheat sheet for the scp command:

scp [options] <source folder/file> <destination folder/file>


  • -r: Recursive copy, copy directories and their contents
  • -P <port>: Specifies the port to use for the SSH connection (default is 22)
  • -v: Verbose mode, displays detailed progress and debug information


#Copy file from local to remote
scp localfile.txt remoteuser@remoteserver:/remote/path/

#Copy directory from local to remote
scp -r localdirectory/ remoteuser@remoteserver:/remote/path/

#Copy file from remote to local
scp remoteuser@remoteserver:/remote/path/remotefile.txt localfile.txt

#Copy directory from remote to local
scp -r remoteuser@remoteserver:/remote/path/remotedirectory/ localdirectory/

# Copy file from local env to AWC EC2 host
scp -i <local path to *.pem file> localfile.txt remoteuser@remoteserver:/remote/path/remotefile.txt