服务器配置ssh密钥登陆

时间:2022-07-22
本文章向大家介绍服务器配置ssh密钥登陆,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、创建秘钥对

ssh-keygen -t rsa *#-t表示加密方式*

连敲三次回车

二、将公钥导入到系统

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

三、修改ssh配置文件

vim /etc/ssh/sshd_config
#禁用密码验证
PasswordAuthentication no
#启用密钥验证
RSAAuthentication yes
PubkeyAuthentication yes

四、重启ssh服务

service sshd restart #centos系统
service ssh restart #ubuntu系统
/etc/init.d/ssh restart #debian系统

Q.E.D.