scp file from remote to local code example

Example 1: scp send file

scp ./file.txt remote_username@remote_ip:/remote/directory

Example 2: scp folder from server to local

scp -r [email protected]:/path/to/foo /home/user/Desktop/

Example 3: copy from remote to local

scp file.txt [email protected]:/remote/directory

Example 4: scp local to remote

scp -i <private_key> ./file.txt remote_username@remote_ip:/remote/directory

Example 5: copy from remote server

scp -i <KEY CERTIFICATE | .ppk or .pem file> <source URL of local server or remote server> <destination URL of local server or remote server>

Example 6: scp send file to remote

dragonmnl@local $ scp -P 2222 file.ext username@domain:~/