安装openssh-server
yum install openssh-server -y
编辑ssh参数
vim /etc/ssh/sshd_config
去掉以下3处的注释:
- 修改端口
- 允许root登录
- 需要密码登陆
然后保存并退出
开启ssh服务
systemctl start sshd.service
设置开机启动
systemctl enable sshd.service
检查ssh服务是否已开启
ps -e|grep sshd
检查端口是否已被监听
netstat -an|grep 22
如还不能访问就在防火墙中添加22号端口
firewall-cmd --permanent --zone=public --add-port=22/tcp
然后重启就完成了
systemctl reload firewalld