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服务

猜你喜欢

转载自www.cnblogs.com/water-sky/p/10221314.html