說明:
伺服器IP:192.168.1.200
管理員帳號:root 密碼:chenyi
普通登入帳號: itchenyi.com 密碼:chenyi
實現目的:
1、配置普通帳號通過密鑰驗證遠程SSH登入伺服器
2、禁用root帳號通過遠程SSH登入伺服器
3、禁用所有帳號通過密碼驗證遠程SSH登入伺服器
具體操作:
1、配置普通帳號通過密鑰驗證遠程SSH登入伺服器
使用普通帳號itchenyi.com登入伺服器操作
ssh-keygen -t rsa #產生密鑰
[itchenyi.com@chenyi ~]$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/itchenyi.com/.ssh/id_rsa): Created directory '/home/itchenyi.com/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/itchenyi.com/.ssh/id_rsa.Your public key has been saved in /home/itchenyi.com/.ssh/id_rsa.pub.The key fingerprint is:b6:4c:c3:3c:24:c1:57:d6:11:b5:8f:f7:37:75:f5:69 itchenyi.com@chenyiThe key's randomart image is:+--[ RSA 2048]----+| .. .o.o+. || .... . . || ... . .|| = o+|| S .E*|| + + ..+|| o .o|| o|| |+-----------------+
[itchenyi.com@chenyi ~]$ cd /home/itchenyi.com/.ssh/ #進入目錄
[itchenyi.com@chenyi ~]$ mv id_rsa.pub authorized_keys #產生驗證檔案
下載伺服器/root/.ssh/id_rsa檔案到本地(這裡採用flashfxp工具下載)
開啟puttygen.exe
下載地址:http://www.itchenyi.com/2911.html
選擇Conversions-Import key開啟上一步下載到本地的檔案id_rsa