阿里云
在創建主機時候直接提供了私鑰公鑰,可以設置秘鑰對
不用配置服務端,好用
客戶端配置
chmod 400 xxx.pem
vi ~/.ssh/config
寫入
Host servicename
HostName 1.1.1.1
User root
IdentityFile ~/.ssh/xxx.pem
配置服務端教程(centos)
創建私鑰省略。。。
[root@host .ssh]$ vi /root/.ssh/authorized_keys
復制公鑰粘貼到/root/.ssh/authorized_keys
[root@host .ssh]$ chmod 600 /root/.ssh/authorized_keys
[root@host .ssh]$ chmod 700 /root/.ssh/
[root@host .ssh]$ vi /etc/ssh/sshd_config
設置私鑰登陸
RSAAuthentication yes
PubkeyAuthentication yes
留意 root 用戶能否通過 SSH 登錄:
PermitRootLogin yes
當你完成全部設置,并以密鑰方式登錄成功后,再禁用密碼登錄:
PasswordAuthentication no
最后,重啟 SSH 服務:
[root@host .ssh]$ service sshd restart