惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

Rat's Blog - Rsync

Windows和Linux VPS/GDrive之间文件夹的实时单向/双向同步教程 - Rat's Blog
通过SSH使用Rsync同步两个VPS的文件 - Rat's Blog
博主: Rat's · 2015-08-12 · via Rat's Blog - Rsync
  •  发布时间:
  •  11382 次浏览
  •   暂无评论
  •  1278 字数
  • 分类: 主机教程
  1.  首页
  2. 正文  
  3. 分享到:

假设:A服务器为源服务器,B服务器为目标服务器,需要把A服务器数据同步到B服务。

1、使用SSH登录A服务器,创建无密码的公共SSH keys

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

得到公共SSH key,似如下代码:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyISE0v+WzNz4kNcyoVGdcuVKamoq8GbEE/jFefWu47urdYEGuowb6Dt+nJl9ZoaSGNknkoUrzICKbxA0NFsJZL4GrRRAsI54UKo5ggUWek17ald1KmohfezF5BJ8DiPPcq5sZmtg18L6uhMk7sQuwMpUTpuy7YQtuGi2xz9Xh+E/mt7+JNGmI6NsqifTd7SIUNCR5lHd/VVTdNxTAArO8vffuNn5GCenBlfilugKGlehcdV7dJTYXwPtuSdTTocwDBYHTPVtTVBmtpG0882QMr7J2iOpIA2jTNl7jY5mUfV+SYOlcRMSlxhs2W/rtfcytSdv4m8hjwSTQANF1xtSxQ== root@weilai

2、使用SSH登录B服务器
创建authorized_keys文件,存储A服务器的公共SSH key。如果没有authorized_keys文件,则创建此文件。

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

编辑authorized_keys文件:

vi ~/.ssh/authorized_keys,按i,粘贴A服务器的公共SH key,之后按esc,:wq保存退出。

3、实战,同步文件
把A服务器(108.55.22.33) /home/wwwroot/xx.zip 同步到 B服务器(104.33.22.11)同样目录下。
使用SSH登录A服务器(108.55.22.33):

rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress /home/wwwroot/xx.zip 104.33.22.11:/home/wwwroot/

原文地址:digitalocean


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/35/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。