centos服務(wù)器配置密鑰登錄

1、生成密鑰文件

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: 確認(rèn)密碼

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

chmod -R 700 /root/.ssh/? ? #設(shè)置權(quán)限,僅當(dāng)前用戶可以讀寫

下載該文件下的id_rsa私鑰文件

2、設(shè)置ssh只能密鑰登錄

vim /etc/ssh/sshd_config? #編輯ssh配置文件

PasswordAuthentication no? #關(guān)閉密碼登錄

systemctl restart sshd? #重啟服務(wù)

注意:一定要在確認(rèn)密鑰文件可以使用后再關(guān)閉密碼登錄

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容