Beginner's Tutorial: Using Rsync to Synchronize Files Between Two VPSs via SSH

Beginner's Tutorial: Using Rsync to Synchronize Files Between Two VPSs via SSH

Assumption: Server A is the source server, Server B is the target server, and the data of Server A needs to be synchronized to Server B.

1. Use SSH to log in to server A and create public SSH keys without password.

ssh-keygen -f ~/.ssh/id_rsa -q -P ""
cat ~/.ssh/id_rsa.pub

Get the public SSH key, like the following code:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyISE0v+WzNz4kNcyoVGdcuVKamoq8GbEE/jFefWu47urdYEGuowb6Dt+nJl9ZoaSGNknkoUrzICKbxA0NFsJZL4GrRRAsI54UKo5ggUWek17ald1KmohfezF5BJ8DiPPcq5sZmtg18L6uhMk7sQuwMpUTpuy7YQtuGi2xz9Xh+E/mt7+JNGmI6NsqifTd7SIUNCR5lHd/VVTdNxTAArO8vffuNn5GCenBlfilugKGlehcdV7dJTYXwPtuSdTTocwDBYHTPVtTVBmtpG0882QMr7J2iOpIA2jTNl7jY5mUfV+SYOlcRMSlxhs2W/rtfcytSdv4m8hjwSTQANF1xtSxQ== [email protected]

2. Use SSH to log in to server B

Create the authorized_keys file to store the public SSH key of server A. If there is no authorized_keys file, create this file.

mkdir ~/.ssh
chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0644 ~/.ssh/authorized_keys

Edit the authorized_keys file:

vi ~/.ssh/authorized_keys, press i, paste the public SH key of server A, then press esc, :wq to save and exit.

3. Actual combat, synchronize files

Synchronize server A (167.88.112.127) /home/wwwroot/tools.zhujiwiki.com/html/bus.zip to the same directory of server B (23.227.177.230).
Use SSH to log in to server A (167.88.112.127):

rsync -avz -e “ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null” –progress /home/wwwroot/tools.zhujiwiki.com/html/bus.zip 23.227.177.230:/home/wwwroot/

via: digitalocean

<<:  Install phpMyBackupPro on CentOS VPS to backup MySQL database

>>:  The process of transferring a domain from Godaddy to NameSilo

Recommend

1HOST: €7.25 per year for virtual hosting and a free top-level domain

1HOST.EU, a Dutch hosting provider, claims to hav...

Tospeed 512MB RAM 100GB Space Novosibirsk KVM VPS Review

Details: Tospeed: 24 yuan/month/512MB memory/150G...

AlphaRacks: $21/year/1GB memory/20GB SSD space/2TB bandwidth/KVM/Los Angeles

AlphaRacks has launched SSD kvm vps, which has mu...

Opened a forum, focusing on hosting reviews, hosting offers, etc.

Welcome to share, merchants are welcome to join, ...

NetworkSolutions $4.95 Domain Name Coupon

Also released for Christmas, it allows registrati...

RootNerds: €5.49/month/1GB RAM/50GB storage/200GB data traffic/OpenVZ/Japan

RootNerds, a German hosting company founded in 20...

[Black Friday] HostMedia: UK KVM VPS, 7.5 pounds per year

Host Media, a formal company, Company Registratio...

$1/month/unlimited space/unlimited traffic virtual host—— Hostbig

Hostbig was founded in 2004 and is an American ho...

Free registration of edu mailbox

As we all know, edu mailbox belongs to the educat...