要上傳的檔案的windows主機使用DeltaCopy這支程式

檔案下載:https://www.itnotetk.com/phpbb/viewtopic.php?f=44&t=972&sid=8d32f24d2a52722ab1fd4f9688f8eed9

rsync

新增一個test.bat執行檔貼上以下命令

rsync -e "ssh -p 22 -i .rsync.key " -avzP --delete --chmod=a=r,Da+x /cygdrive/D/\test/" [email protected]:/opt/test/

此指令是上傳D槽底下的/test/底下檔案到linux上的/opt/test/底下

192.168.1.20是要被上傳的主機,因為windows不能產生公私鑰所以需要另外的linux主機來產出

192.168.1.17→產生公私鑰的機器

輸入ssh-keygen一直按enter中途會問key名稱及是否需要密碼 範例是不需要

會出現id_rsa、id_rsa.pub

[[email protected] .ssh]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
3f:10:42:14:0a:79:fd:c4:a1:6b:10:b7:4c:8f:f0:d7 [email protected]

rsync01

1.在192.168.1.17上cat id_rsa.pub

[[email protected] .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwTC5FQlxIIF2TfEXm1tp75dG39p6kNbVZ2Xnvnv8Rv+sZkdoDvnjmbk3vzhyec9zycZ3IB3Hc4qFrmxu3edAA0aGJ8VqbHXBY6Id+ED/VOFYxBqrBJaFJWF0DAUPOJ1C4L7V7PthZLJWdppCh+nRTjGMndqajV6PpIk6O3oK3kcXo54RPRolujIGj2WVZWYkOy1bZ5KWQw2+p9pBLuZGv6CFyL00D18Rz2e6GHePL5cpxeVYETbvokXJIYFqmhIB2fDBaAK+oMKqSupen58X07zZzDFSaXb7ToKkwv5vi67AWukZ1X4Ua4s6JGsn4LNElGSp9dgZo6XbXEM10SLHIw== [email protected]

複製內容貼到被上傳的主機192.168.1.20的使用者帳號底下的.ssh/authorized_keys

[[email protected] .ssh]# cat auth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

rsync02

執行test.bat測試上傳,第一次執行會出現此訊息請按yes

rsync03

上傳成功會出現以下畫面

rsync05

點閱: 282

By tony

自由軟體愛好者~喜歡不斷的思考各種問題,有新的事物都會想去學習嘗試 做實驗並熱衷研究 沒有所謂頂天的技術 只有謙虛及不斷的學習 精進專業,本站主要以分享系統及網路相關知識、資源而建立。 Github http://stnet253.github.io

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料