1.生成私钥
ssh-keygen -t rsa
- 执行后首先提示输入保存位置,不输入为默认位置:
/root/.ssh
- 然后提示输入密码,不输入,无密码
- 再次输入确认密码
2.进入/root/.ssh/目录,在服务器上安装公钥,执行
cd /root/.ssh/
cat id_rsa.pub >> authorized_keys
3.文件授权
chmod 600 authorized_keys
chmod 700 ~/.ssh
4.编辑 配置文件
vi /etc/ssh/sshd_config
shirt+G跳转底部,在底部加以下代码,:wq保存退出
RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin yes
5.当你完成全部设置,并以密钥方式登录成功后,再禁用密码登录
在/etc/ssh/sshd_config 文件 添加以下参数
PasswordAuthentication no
6.重启SSH服务,生效
service sshd restart
感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
暂无评论内容