0
我必須從一臺服務器移動文件到其他服務器,我使用shell腳本來自動scp命令
scp [email protected]:sourcefilepath [email protected]:destdirectory
當我執行這個腳本它要求的源和目標的密碼這。這個scp命令是否可以包含在shell腳本中,以便動態選取密碼?與文件名和文件路徑一起?
我必須從一臺服務器移動文件到其他服務器,我使用shell腳本來自動scp命令
scp [email protected]:sourcefilepath [email protected]:destdirectory
當我執行這個腳本它要求的源和目標的密碼這。這個scp命令是否可以包含在shell腳本中,以便動態選取密碼?與文件名和文件路徑一起?
您可以通過爲兩臺服務器生成私鑰/公鑰來解決此問題。
稍後使用ssh-keygen
和ssh-copy-id
將您的公鑰複製到兩臺服務器。
步驟:
ssh-keygen
ssh-copy-id [email protected]
ssh-copy-id [email protected]
scp -3 [email protected]:sourcefilepath [email protected]:destdirectory
通知的-3
選項,這將sourceservername將文件傳輸到本地服務器,然後再到destservername。這樣你將只有一對私鑰/公鑰。
嗨@krzyk - 你能告訴我確切的順序和eact命令嗎? –
[無密碼SSH](http://www.linuxproblem.org/art_9.html)可以幫助你在這裏。 –