Search Our Database

How to setup rsync without password

Last updated on |
under |
by

Introduction

This article provides a step-by-step guide to configure rsync for secure, passwordless file transfers between two remote systems using SSH. It is intended for users who frequently use rsync for data synchronization or backups and wish to eliminate the need to enter a password manually each time. By setting up SSH key-based authentication, you can automate the rsync process while maintaining security.

 

Prerequisites

Before proceeding, ensure you have the following:

  • Access to both the server (source and destination server)
  • Basic knowledge of SSH and terminal commands.
  • SSH is installed on both the local and remote server.

 

Step-by-step guide

*For easier explanation:

  • Server A refers to the local machine (the system initiating the rsync).
  • Server B refers to the remote machine (the system receiving the files).

 

Step 1: Generate SSH keys on Server A

  • Run the following command to generate an SSH key pair:
ssh-keygen -t rsa
  • You will be prompted for a file location to save the keys. Press Enter to accept the default location (~/.ssh/id_rsa).
  • When asked for a passphrase, press Enter twice to create a key with no passphrase.

 

Step 2: Copy the SSH public key from Server A to Server B

  • Use the following command to copy the public key id_rsa.pub from Server A to the authorized keys file on Server B.
  • Replace remote_user with the username on Server B and remote_host with the IP address or domain of Server B:
ssh-copy-id remote_user@remote_host
  • You will be prompted to enter the password for the user on Server B. After entering the correct password, the public key will be added to Server B.

 

Step 3: Test the SSH connection between Server A and Server B

  • To verify that the passwordless SSH login works, try connecting from Server A to Server B using SSH:
ssh remote_user@remote_server_ip
  • If successful, you will not be prompted for a password, confirming that key-based authentication is configured correctly.

 

Step 4: Use rsync between Server A and Server B without a password

  • Now that SSH is configured for passwordless login, you can use rsync to transfer files from Server A to Server B. Here’s an example command to sync files from the directory /local/path/ on Server A to /remote/path on Server B:
rsync -avz /local/path/ remote_user@remote_host:/remote/path/

  • The rsync command should now execute without prompting for a password, using the SSH key for authentication.

 

Conclusion

By following these steps, you can set up rsync for passwordless file transfers between Server A and Server B using SSH key-based authentication. This setup simplifies automated backups or file synchronization processes. If issues arise, ensure the SSH keys are correctly configured and that the authorized_keys file on Server B has the correct permissions.

For additional assistance or if you encounter any issues, please contact our support team at support@ipserverone.com.