欢迎光临
我们一直在努力

CentOS修改SSH端口后,重启未监听端口

一,修改端口

修改 /etc/ssh/sshd_config

[root@ihh-9 ~]# cat /etc/ssh/sshd_config |  grep Port
Port 22
Port 3538

重启 sshd

[root@ihh-9 ~]# systemctl restart sshd

检查 新端口未监听

[root@ihh-9 ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      30632/sshd

解决

[root@ihh-4 queues]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-04-10 13:08:25 CST; 2min 8s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 30632 (sshd)
   CGroup: /system.slice/sshd.service
           └─30632 /usr/sbin/sshd -D

Apr 10 13:08:25 ihh-4 systemd[1]: Starting OpenSSH server daemon...
Apr 10 13:08:25 ihh-4 sshd[30632]: error: Bind to port 3538 on 0.0.0.0 failed: Permission denied.
Apr 10 13:08:25 ihh-4 sshd[30632]: error: Bind to port 3538 on :: failed: Permission denied.
Apr 10 13:08:25 ihh-4 sshd[30632]: Server listening on 0.0.0.0 port 22.
Apr 10 13:08:25 ihh-4 sshd[30632]: Server listening on :: port 22.
Apr 10 13:08:25 ihh-4 systemd[1]: Started OpenSSH server daemon.

Apr 10 13:08:25 ihh-4 sshd[30632]: error: Bind to port 3538 on 0.0.0.0 failed: Permission denied.
Apr 10 13:08:25 ihh-4 sshd[30632]: error: Bind to port 3538 on :: failed: Permission denied.

因为 当前开启 SELinux , 关闭 SELinux 即可 或这添加 白名单

# semanage port -a -t ssh_port_t -p tcp 3538

 

赞(0) 打赏
转载请注明来源:IT技术资讯 » CentOS修改SSH端口后,重启未监听端口

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏