您好,登錄后才能下訂單哦!
代碼
[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:1c root@Client
[root@Client root]#
注意:在程序提示輸入passphrase時(shí)直接輸入回車,表示無證書密碼。
上述命令將生成私鑰證書id_rsa和公鑰證書id_rsa.pub,存放在用戶家目錄的.ssh子目錄中。
2. 將公鑰證書id_rsa.pub復(fù)制到機(jī)器Server的root家目錄的.ssh子目錄中,同時(shí)將文件名更換為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: <-- 輸入機(jī)器Server的root用戶密碼
id_rsa.pub 100% |**************************| 218 00:00
[root@Client root]#
在執(zhí)行上述命令時(shí),兩臺機(jī)器的root用戶之間還未建立安全信任關(guān)系,所以還需要輸入機(jī)器Server的root用戶密碼。
經(jīng)過以上2步,就在機(jī)器Client的root和機(jī)器Server的root之間建立安全信任關(guān)系。下面我們看看效果:
[root@Client root]# scp -p text root@192.168.3.206:/root
text 100% |**************************| 19 00:00
[root@Client root]#
成功了!真的不再需要輸入密碼了。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。