Home

How to upload/download files via SSH using an identity file and SCP

Using a private/public RSA key pair is good practice for securely accessing your remote servers.

If you are like me, more than once you forgot how to use the RSA identity file with scp to secure copy files via SSH.

Bellow is your copy pasting joy.

Download Specific File

Command structure:

$ sudo scp -C -i <path-to-file-identity-file> \
  <remote-user>@<remote-ip>:<full-path-to-file> <full-local-path-where-to-save>

Example usage:

$ sudo scp -C -i ~/Desktop/openssh \
  admin@135.201.228.237:/home/admin/Desktop/my-file.txt /home/devimal/Desktop/my-file.txt

Upload Specific File

Command structure:

$ sudo scp -C -i <path-to-file-identity-file> \
  <full-path-to-file> <remote-user>@<remote-ip>:<full-path-to-save>

Example usage:

$ sudo scp -C -i ~/Desktop/openssh \
  /home/devimal/Desktop/my-file.txt admin@135.201.229.236:/home/admin/Desktop/my-file.txt

Download Folder

Command structure:

$ sudo scp -C -i <path-to-file-identity-file> \
  -r <remote-user>@<remote-ip>:<full-path-to-folder> <full-local-path-where-to-save>

Example usage:

$ sudo scp -C -i ~/Desktop/openssh \
  -r admin@135.201.229.236:/home/admin/Desktop/my-folder /home/devimal/Desktop/my-folder

Upload Folder

Command structure:

$ sudo scp -C -i <path-to-file-identity-file> \
  -r <full-path-of-folder-to-upload> <remote-user>@<remote-ip>:<full-path-to-folder-where-to-save>

Example usage:

$ sudo scp -C -i ~/Desktop/openssh \
  -r /home/devimal/Desktop/my-folder admin@135.201.229.236:/home/admin/Desktop/my-folder