- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
SSH密鑰對僅支持Linux系統創建。
打開終端,輸入以下指令,查看是否已經生成SSH秘鑰。
如果有文件id_rsa.pub 或 id_dsa.pub 說明已經創建過SSH密鑰,導入即可。
ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
生成新的SSH密鑰。
在服務器上制作密鑰對。首先用密碼登錄到你打算使用密鑰登錄的賬戶,然后執行以下命令:
[root@host ~]$ ssh-keygen <== 建立密鑰對
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): <== 按 Enter
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): <== 輸入密鑰鎖碼,或直接按 Enter 留空
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: xxxxxxx
創建完成,安裝公鑰。
輸入以下命令,在服務器上安裝公鑰:
如此便完成了公鑰的安裝。為了確保連接成功,請保證以下文件權限正確:
[root@host .ssh]$ chmod 600 authorized_keys
[root@host .ssh]$ chmod 700 ~/.ssh
[root@host ~]$ cd .ssh
[root@host .ssh]$ cat id_rsa.pub >> authorized_keys
設置SSH,打開密鑰登錄。
編輯 /etc/ssh/sshd_config 文件,進行如下設置:
另外,請留意 root 用戶能否通過 SSH 登錄:
當你完成全部設置,并以密鑰方式登錄成功后,再禁用密碼登錄:
最后,重啟 SSH 服務:
[root@host .ssh]$ service sshd restart
PasswordAuthentication no
PermitRootLogin yes
RSAAuthentication yes
PubkeyAuthentication yes
提交成功!非常感謝您的反饋,我們會繼續努力做到更好!
這條文檔是否有幫助解決問題?
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP