CentOS Linux創(chuàng)建私鑰與SSH配置文件
向大家詳細介紹CentOS Linux創(chuàng)建公鑰與私鑰,首先讓大家了解下CentOS Linux系統(tǒng),然后全面介紹CentOS Linux創(chuàng)建,希望對大家有用。CentOS Linux和與之對應版本號的RHEL發(fā)行版具有軟件包級別的二進制兼容性,即某個RPM軟件包如果可以安裝運行在RHEL產(chǎn)品中,就可以正常地安裝運行在對應版本的CentOS Linux中。CentOS Linux創(chuàng)建安全的私鑰文件。
1、CentOS Linux創(chuàng)建進入sshd_config(/etc/ssh/sshd_config)#ServerKeyBits 768ServerKeyBits 1024 修改加密強度為1024bit#PasswordAuthentication yes
PasswordAuthenticatino no 不允許密碼方式登陸#PermitEmptyPasswords onPermitEmptyPasswords no 禁止空密碼登陸
2、CentOS Linux創(chuàng)建修改hosts.deny(/etc/hosts.deny)文件,禁止所有的SSH連接。在hosts.deny文件末尾加上sshd:ALL
3、CentOS Linux創(chuàng)建修改hosts.allow(/etc/hosts.allow)文件,加上允許進行SSH連接的IP地址或IP地址段。在hosts.allow文件末尾加上sshd:IP地址或IP地址段
4、CentOS Linux創(chuàng)建重啟SSH服務service sshd restart
5、CentOS Linux創(chuàng)建公鑰與私鑰文件[root@CentOS~]ssh-keygen -t rsa 創(chuàng)建公鑰與私鑰Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): ← 鑰匙的文件名,這里保持默認直接回車Created directory '/root/.ssh'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:
tf:rs:e3:7s:28:59:5s:93:fe:33:84:01:cj:65:3b:8e root@CentOS~[root@CentOS ~]# cd ~/.ssh ← 進入用戶SSH配置文件的目錄[root@CentOS ~]# ls -l ← 列出文件total 16 -rw------- 1 root root 951 Sep 4 19:22 id_rsa ← 確認私鑰已被建立-rw-r--r-- 1 root root 241 Sep 4 19:22 id_rsa.pub ← 確認公鑰已被建立
[root@CentOS ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ← 公鑰內(nèi)容輸出到相應文件中
[root@CentOS ~]# rm -f ~/.ssh/id_rsa.pub ← 刪除原來的公鑰文件
[root@CentOS ~]# chmod 400 ~/.ssh/authorized_keys ← 將新建立的公鑰文件屬性設(shè)置為400
6、CentOS Linux導出id_rsa文件
7、使用PuTTY工具組里的PuTTYGen來轉(zhuǎn)換私鑰,打開PuTTYGen,選擇“載入”,選擇剛才的“id_rsa”文件(選擇文件的時候,文件類型改為“所有文件(*.*)”),輸入剛才創(chuàng)建公鑰與私鑰時候的密碼,便可以轉(zhuǎn)缼成功,并選擇“保存私鑰”。
8、在用PuTTY登陸Linux系統(tǒng)的時候,在下面的“SSH”-“認證”里,在“認證私鑰文件處”選擇剛才轉(zhuǎn)換的私鑰文件即可進行登陸。以上介紹CentOS Linux系統(tǒng)創(chuàng)建。
【編輯推薦】