1. 程式人生 > >github生成公鑰程式碼

github生成公鑰程式碼

centos生成公鑰私鑰 securecrt通過公鑰訪問伺服器 winscp通過公鑰訪問伺服器

忙碌了一下午,一直到寫部落格現在。都在糾結阿里雲伺服器上配置公鑰私鑰,網上的說辭總是參差不齊,需要各個去綜合,合理取捨。今天終於配置好了。

我就不說這種方式的重要性了,往往黑客都不需要你的登陸賬戶密碼就能上你的伺服器,多麼可怕。比如【redis後門】自己百度哈。

直入主題:

[[email protected] .ssh]$ ssh-keygen -C"liyongdada" -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:
d2:5f:a7:c4:fa:66:1d:b8:64:49:31:03:e5:d8:3b:6eliyongdada
The key’s randomart image is:
±-[ RSA 2048]----+
| .o. |
| ++ |
| . o+ |
| . … |
| . S .*o. |
| . . ==+. |
| ooEo . |
| o+ . |
| o. |
±----------------+
[

[email protected] .ssh]$ ls
id_rsa id_rsa.pub
執行完這個命令後,在/root/.ssh/目錄有兩個檔案,黃色是私鑰,綠色是公鑰。還需要做一件事!

執行 cat id_rsa.pub >> authorized_keys 公鑰內容輸出到相應檔案中

執行 rm -f id_rsa.pub  刪除原來的公鑰檔案

執行   chmod 400 authorized_keys   將新建立的公鑰檔案屬性設定為400

接下來配置conf檔案:

執行  : vim /etc/ssh/sshd_config