SCP 不输入密码
以下是在機器Client的root和機器Server的root之間建立安全信任關系的步驟:
? ? 1. 在機器Client上root用戶執行ssh-keygen命令,生成建立安全信任關系的證書。
? ? ? ?[root@Client root]# ssh-keygen -b 1024 -t rsa
? ? ? ? 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:
? ? ? ? 49:9c:8a:8f:bc:19:5e:8c:c0:10:d3:15:60:a3:32:1croot@Client
? ? ? ? [root@Client root]#
? ?注意:在程序提示輸入passphrase時直接輸入回車,表示無證書密碼 。
? ? 上述命令將生成私鑰證書id_rsa和公鑰證書id_rsa.pub,存放在用戶家目錄的.ssh子目錄中。
? ? 2. 將公鑰證書id_rsa.pub復制到機器Server的root家目錄的.ssh子目錄中,同時將文件名更換為authorized_keys。
? ? ? ?[root@Client root]# scp -p .ssh/id_rsa.pub root@192.168.3.206:/root/.ssh/authorized_keys
? ? ? ?root@192.168.3.206's password: ? ? ? ? ?<-- 輸入機器Server的root用戶密碼
? ? ? ? id_rsa.pub ? ? ? ? ? 100% |**************************| ? 218 ? ? ? 00:00
? ? ? ? [root@Client root]#
? ? 在執行上述命令時,兩臺機器的root用戶之間還未建立安全信任關系,所以還需要輸入機器Server的root用戶密碼。
? ? 經過以上2步,就在機器Client的root和機器Server的root之間建立安全信任關系。下面我們看看效果:
? ? ? ? [root@Client root]# scp -p textroot@192.168.3.206:/root
? ? ? ? text ? ? ? ? ? ? ? ? 100% |**************************| ? ?19 ? ? ? 00:00
########################################################################################
注:
(1)如果把A的公鑰給了B,那么,可以在A上SCP不輸入密碼,進行傳輸B中的數據;
但 B上SCP時,仍需要密碼,如果需要雙方不輸入 密碼,則也要把B的公鑰給A;
(2)如果想讓B,C同時可以SCP不輸入密碼,傳輸A中的數據;
則要把B、C的公鑰都給 A;
操作步驟:把兩機器的id_rsa.pub中的數據都拷貝到A的/root/.ssh/authorized_keys文件中,一行表示一條;
? ? ? ? ?或使用scp -p .ssh/id_rsa.pub root@192.168.3.206:/root/.ssh/authorized_keys 先遠程拷貝過去一個,然后,另一個再手動拷貝進去;
轉載于:https://blog.51cto.com/gugpu/1551384
總結
- 上一篇: 树莓派搭建minecraft服务器
- 下一篇: SqlServer动态表查询