1. 程式人生 > >xshell祕鑰登入伺服器

xshell祕鑰登入伺服器

一、root使用者

1、生成公鑰私鑰

ssh-keygen -t rsa

私鑰自己下載到本地電腦妥善儲存(丟了伺服器可就沒法再登陸了),為安全,建議刪除伺服器端的私鑰。公鑰則可以任意公開。

2、cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

3、修改SSH的配置檔案/etc/ssh/sshd_config

#PubkeyAuthentication yes

4、關閉root密碼登入

PasswordAuthentication no

5、重啟服務

service sshd restart

二、普通使用者

1、執行一中的12步驟

2、修改配置檔案

StrictModes yes --> StrictModes no  ## 關閉嚴格模式

3、重啟sshd服務