人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

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

發(fā)布日期:2022-02-08 15:30 | 文章來源:源碼中國

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

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

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

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

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

SSH密鑰認證登錄配置

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

客戶端ip:192.168.72.11

服務(wù)器ip:192.168.72.129

密鑰認證的生成


復(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ù)器要進行確認
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è)置公鑰認證登錄

將下邊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 密鑰認證無需輸入密碼即可登錄,在設(shè)置密鑰的同時,也可以輸入密碼,即可密碼+密鑰認證就可以完成!

美國服務(wù)器租用

版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部