Copy files between Linux machines

The rsync command allows you to copy files using SSH connection, between your workstation and another Linux machine. You have to be logged into one of the machines, this command cannot copy files between two remote machines.

To copy a file from your local machine to a remote server

rsync -avz -e "ssh -i SSH_KEY_FILE -o 'StrictHostKeyChecking=no'" --rsync-path="sudo rsync" SOURCE_FILE USER_NAME@SERVER_IP:TARGET_DIRECTORY/

To copy a file from a remote server to your local workstation

rsync -avz -e "ssh -i SSH_KEY_FILE -o 'StrictHostKeyChecking=no'" --rsync-path="sudo rsync" USER_NAME@SERVER_IP:SOURCE_FILE TARGET_DIRECTORY/

Leave a comment

Your email address will not be published. Required fields are marked *