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

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

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个机房按小时计费,支持支付宝,【点击查看】。