linux-scp不輸入密碼配置

轉自:http://blog.163.com/fancy_duan/blog/static/97006820119961024749/

 

以下是在機器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 [email protected]:/root/.ssh/authorized_keys
[email protected]'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 text [email protected]:/root
text 100% |**************************| 19 00:00

########################################################################################

 

linux-scp不輸入密碼配置 - Fantasy - Fantasy的博客linux-scp不輸入密碼配置 - Fantasy - Fantasy的博客linux-scp不輸入密碼配置 - Fantasy - Fantasy的博客


3.上面說的是兩臺服務器直接建立信任,如果有多臺client都要對同一臺server建立信任呢,那就直接把各client的id_rsa.pub的內容都加到文件authorized_keys後面就可以了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章