国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

創(chuàng )建SSH密鑰對

2019-01-03 23:54:37 6948

使用限制

SSH密鑰對僅支持Linux系統創(chuàng )建。

創(chuàng )建SSH密鑰操作步驟

  1. 使用VNC服務(wù)器賬號密碼連接Linux實(shí)例。

  2. 打開(kāi)終端,輸入以下指令,查看是否已經(jīng)生成SSH秘鑰。


    如果有文件id_rsa.pub 或 id_dsa.pub 說(shuō)明已經(jīng)創(chuàng )建過(guò)SSH密鑰,導入即可。

    1. ls -al ~/.ssh

    2. # Lists the files in your .ssh directory, if they exist

  3. 生成新的SSH密鑰。

    在服務(wù)器上制作密鑰對。首先用密碼登錄到你打算使用密鑰登錄的賬戶(hù),然后執行以下命令:


    1. [root@host ~]$ ssh-keygen <== 建立密鑰對

    2. Generating public/private rsa key pair.

    3. Enter file in which to save the key (/root/.ssh/id_rsa): <==  Enter

    4. Created directory '/root/.ssh'.

    5. Enter passphrase (empty for no passphrase): <== 輸入密鑰鎖碼,或直接按 Enter 留空

    6. Enter same passphrase again: <== 再輸入一遍密鑰鎖碼

    7. Your identification has been saved in /root/.ssh/id_rsa. <== 私鑰

    8. Your public key has been saved in /root/.ssh/id_rsa.pub. <== 公鑰

    9. The key fingerprint is: xxxxxxx

  4. 創(chuàng )建完成,安裝公鑰。

    輸入以下命令,在服務(wù)器上安裝公鑰:


    如此便完成了公鑰的安裝。為了確保連接成功,請保證以下文件權限正確:


    1. [root@host .ssh]$ chmod 600 authorized_keys

    2. [root@host .ssh]$ chmod 700 ~/.ssh

    3. [root@host ~]$ cd .ssh

    4. [root@host .ssh]$ cat id_rsa.pub >> authorized_keys

  5. 設置SSH,打開(kāi)密鑰登錄。

    編輯 /etc/ssh/sshd_config 文件,進(jìn)行如下設置:


    另外,請留意 root 用戶(hù)能否通過(guò) SSH 登錄:


    當你完成全部設置,并以密鑰方式登錄成功后,再禁用密碼登錄:


    最后,重啟 SSH 服務(wù):


    1. [root@host .ssh]$ service sshd restart

    2. PasswordAuthentication no

    3. PermitRootLogin yes

    4. RSAAuthentication yes

    5. PubkeyAuthentication yes


    提交成功!非常感謝您的反饋,我們會(huì )繼續努力做到更好!

    這條文檔是否有幫助解決問(wèn)題?

    非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

    在文檔使用中是否遇到以下問(wèn)題:
    -->