centos配置私鑰登錄

一.生成密鑰的公鑰和私鑰

  1.ssh-keygen -t rsa 

二.將生成的私鑰(id_rsa)下載到本地的windows機,並把公鑰導入到.ssh/authorized_keys 文件中去

      1.#cd /root/.ssh/

  2.#cat id_rsa.pub > authorized_keys 

三.sshd配置

   1.sshd配置文件路徑 /etc/ssh/sshd_config

   2.

四.設置sshd  服務器服務,打開以下設置:

    1. RSAAuthentication yes 

    2. PubkeyAuthentication yes

    3. AuthorizedKeysFile      /root/.ssh/authorized_keys

    4. ChallengeResponseAuthentication no 

    5. PasswordAuthentication no 

    6. UsePAM no 

五.重啓ssh服務

    1.   #service ssh  restart (注意:如果是centos7以下版本)

    2.如果是centos7以上  

    查看ssh服務狀態:systemctl status sshd.service

    開啓ssh服務:systemctl start sshd.service

    重啓ssh服務:systemctl restart sshd.service

      服務器自動開啓:systemctl enable sshd.service

六.xshell登錄

    添加id_rsa私鑰文件,輸入建立私鑰時候的密碼,就成功了。

    6b46195ebd1eaed5c52ce8838f23e7e9.png-wh_

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章