网站建设需什么软件,软件开发外包合同模板,服务器怎样建设网站,汕头百度公司多开几个ssh#xff0c;防止配置文件错误#xff0c;将自己关在服务器外面了 netstat -ntlp|grep ssh # ssh对应的端口号
修改sshd_config配置文件 /etc/ssh/sshd_config#xff0c;重启sshd服务
#Port 22
Port 10011 # 端口号自己定义#xff0c;不能超过65535#xf… 多开几个ssh防止配置文件错误将自己关在服务器外面了 netstat -ntlp|grep ssh # ssh对应的端口号
修改sshd_config配置文件 /etc/ssh/sshd_config重启sshd服务
#Port 22
Port 10011 # 端口号自己定义不能超过65535建议10000-65535同时要记得在防火墙中开放端口号
systemctl restart sshd # 修改端口后需重启服务生效
重启sshd服务报错
Job for sshd.service failed because the control process exited with error code. See systemctl status sshd.service and journalctl -xe for details.这个时候新建连接发现22端口也连不上只能在之前开的窗口上将修改的还原。 一、修改sshd_config配置文件 /etc/ssh/sshd_config
Port 22
Port 10011 # 两个都放开等10011弄好了再关闭22端口 二、重启sshd服务 重启显示正常但还是有个报错
localhost.localdomain sshd[1616]: error: Bind to port 10011 on 0.0.0.0 failed: Permission denied.
localhost.localdomain sshd[1616]: error: Bind to port 10011 on :: failed: Permission denied.
三、解决办法一后发现不可取
查询资料说是SELinux的问题修改 /etc/selinux/config 文件中设置 关闭SELinux
#SELINUXenforcing
SELINUXdisabled 修改完后重启服务器 reboot 发现运行正常 四、什么是SELinux
第三步虽然解决了问题但百度查了下百度下SELinux SeLinux全称Security-Enhanced Linux即安全增强型Linux它是一个Linux内核模块也是Linux的一个安全子系统。 SELinux主要作用就是最大限度地减小系统中服务进程可访问的资源设想一下如果一个以root身份运行的网络服务存在0day漏洞黑客就可以利用这个漏洞以root的身份在您的服务器上为所欲为了SeLinux就是来解决这种问题的。 参考博客 https://www.cnblogs.com/quqibinggan/p/13289693.html
看到这第三步的操作好像不可取将第三步操作还原并重启服务器。
五、解决办法二可取
semanage port -l|grep ssh # SELinux允许的ssh端口号# 没有需要先安装
yum provides semanage
yum install policycoreutils-python -ysemanage port -a -t ssh_port_t -p tcp 10011systemctl restart sshd到这里ssh新增了一个端口号10011使用ssh连接工具也是可以连接的测试完成后再编辑 /etc/ssh/sshd_config 文件将22端口注释掉只保留10011端口可降低服务器被恶意ssh攻击风险。