rsync 信任ssh 免密傳輸文件
準備工作
2臺服務器
A:192.168.1.100 傳輸用
B:192.168.1.200 接收用
2臺服務器都需要有一個相同登錄用戶 這裏都用root
# 安裝SSH
sudo apt-get install openssh-server
#啓動ssh服務
sudo service ssh start
生成公私鑰對
A服務器
ssh-keygen -t rsa -P ''
#-P表示密碼password,-P '' 就表示空密碼 也可以直接 ssh-keygen
將公鑰複製到B服務器
sudo vim /root/.ssh/authorized_keys
# 如果沒有權限則chmod 600 /root/.ssh/authorized_keys
# 將A服務器id_rsa.pub (默認公鑰名可改,路徑也在 /root/.ssh 中) 的內容複製到 B服務器的 authorized_keys 中
測試傳輸
A服務器
rsync -avz -e ssh /www/index.php [email protected]:/www/test/
# 將 A服務器 的/www/index.php 傳輸到 B服務器 的/www/test/中