ssh免密登录
(1)查看是否安装ssh服务器
[root@localhost ~]# rpm -qa|grep ssh-server
openssh-server-7.4p1-16.el7.x86_64//已经安装了,如果没有安装执行第(2)步安装。
(2)安装telnet-server
[root@localhost etc]# yum install openssh-server
(3)配置SSH服务器
(3-1)通过口令验证方式登录
1)用vim编辑器或vi编辑器打开sshd_config
vim /etc/ssh/sshd_config
2)修改配置文件
Port 22
PermitRootLogin no //禁止root账户远程登录
PasswordAuthentication yes//启用口令认证方式
PermitEmptyPasswords no//禁止使用空密码
LoginGraceTime 2m//重复验证时间为2分钟
MaxAuthTries 6//最大重试次数
修改好后保存退出(:wq)
3)重启sshd服务
service sshd restart
或systemctl restart sshd.service
(3-2)通过秘钥对验证方式登录
1)生成默认格式的密匙key。
此过程会在/root/.ssh/文件件夹下生成id_rsa(私钥)和id_rsa.pub(公钥)。
[root@mylocalhost ~]$ ssh-keygen -t rsa
2)查看/root/.ssh/目录
3)查询服务端(其他客户端)IP地址
4)将客户端公钥发送给服务端(其他客户端)
ssh-copy-id [email protected]
5)经过ssh-copy-id后接收公钥的服务端会把公钥追加到服务端对应用户的$HOME/.ssh/authorized_keys文件中
6)ssh免密登录