欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

通過SSH進行密鑰認(rèn)證自動登錄Linux服務(wù)器

大步's blog   發(fā)布時間:2015-07-07 16:15:01   作者:佚名   我要評論
這篇文章主要介紹了通過SSH進行密鑰認(rèn)證自動登錄Linux服務(wù)器,同時也可再另外在Linux系統(tǒng)的服務(wù)器上設(shè)置密碼登錄實現(xiàn)雙重安全保障,需要的朋友可以參考下

傳統(tǒng)的網(wǎng)絡(luò)服務(wù)程序,SSH的英文全稱是 Secure Shell,通過使用ssh,可以對所有的傳輸?shù)臄?shù)據(jù)進行加密,這樣既可以防止攻擊又可以防止IP欺騙。

SSH 提供2種級別的安全驗證

1,基于口令的安全驗證,這也是我們常用的一種,只要知道用戶名和密碼,就可以遠程登陸到遠程主機上。

2,基于密鑰的安全認(rèn)證,就是說用戶必須為自己創(chuàng)建一對密鑰,并把公用密鑰放到需要訪問的服務(wù)器上。

2種安全級別的驗證,后者相對比前者更安全一些,第二種級別不需要在網(wǎng)絡(luò)上傳遞口令。

SSH密鑰認(rèn)證登錄配置

原理:用戶首先需要為自己創(chuàng)建一對密鑰:公鑰(用在登錄的服務(wù)器上)和私鑰。OPENSSH 公開的密鑰的密碼體質(zhì)有RSA,DSA等,這里就用RSA。

客戶端ip:192.168.72.11

服務(wù)器ip:192.168.72.129

密鑰認(rèn)證的生成


復(fù)制代碼
代碼如下:
[root@xyly ~]# ifconfig eth0 | awk ‘/inet addr/{print }’
inet addr:192.168.72.11 Bcast:192.168.72.255 Mask:255.255.255.0</p> <p>[root@xyly ~]# ssh-keygen -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:
04:c5:7a:57:f6:2e:9c:1f:b5:e7:45:b3:11:f3:c7:18 root@xyly

公鑰已經(jīng)生成

現(xiàn)在把公鑰上傳到另一臺服務(wù)器上去。


復(fù)制代碼
代碼如下:
[root@xyly ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.72.129
The authenticity of host ’192.168.72.129 (192.168.72.129)’ can’t be established.
RSA key fingerp
rint is 3b:26:19:2e:51:ca:cc:de:ac:bc:00:09:f0:7c:7d:f1.
Are you sure you want to continue connecting (yes/no)? yes #由于是第一次登錄,服務(wù)器要進行確認(rèn)
Warning: Permanently added ’192.168.72.129′ (RSA) to the list of known hosts.
Address 192.168.72.129 maps to localhost, but this does not map back to the address – POSSIBLE BREAK-IN ATTEMPT!
root@192.168.72.129′s password:
Now try logging into the machine, with “ssh ‘root@192.168.72.129′“, and check in:</p> <p>.ssh/authorized_keys #把公鑰上傳的位置和公鑰的文件名</p> <p>to make sure we haven’t added extra keys that you weren’t expecting.

登錄到服務(wù)器上,查看公鑰是否上傳


復(fù)制代碼
代碼如下:
[root@localhost ~]# ll .ssh/authorized_keys
-rw——- 1 root root 391 Aug 4 18:31 .ssh/authorized_keys

說明公鑰上傳成功了。

修改ssh配置文件,設(shè)置公鑰認(rèn)證登錄

將下邊2行的注釋去掉,重啟ssh服務(wù)


復(fù)制代碼
代碼如下:
RSAAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys</p> <p>/etc/init.d/sshd restart

配置完畢,現(xiàn)在開始登錄一下


復(fù)制代碼
代碼如下:
[root@xyly ~]# ssh 192.168.72.129
Address 192.168.72.129 maps to localhost, but this does not map back to the address – POSSIBLE BREAK-IN ATTEMPT!
Last login: Thu Aug 4 18:08:05 2011 from 192.168.72.1
[root@localhost ~]#

現(xiàn)在不用輸入密碼,就可以登錄了。退出登錄


復(fù)制代碼
代碼如下:
[root@localhost ~]# exit
logout
Connection to 192.168.72.129 closed.

linux ssh 密鑰認(rèn)證無需輸入密碼即可登錄,在設(shè)置密鑰的同時,也可以輸入密碼,即可密碼+密鑰認(rèn)證就可以完成!

相關(guān)文章

最新評論