帮助中心

SSH默认端口修改 打印

  • 3

如何修改ssh默认端口
修改的是 /etc/ssh/sshd_config 文件

  1. [root@linux ~]# vi /etc/ssh/sshd_config
  2. # $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
  3. # This is the sshd server system-wide configuration file. See
  4. # sshd_config(5) for more information.
  5. # This sshd was compiled with PATH=/usr/local/bin:/usr/bin
  6. # The strategy used for options in the default sshd_config shipped with
  7. # OpenSSH is to specify options with their default value where
  8. # possible, but leave them commented. Uncommented options override the
  9. # default value.
  10. # If you want to change the port on a SELinux system, you have to tell
  11. # SELinux about this change.
  12. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
  13. #
  14. Port 10008 //默认是有 # 号的,而且默认是 22 ,修改一下就ok了
  15. #AddressFamily any
  16. #ListenAddress 0.0.0.0
  17. #ListenAddress ::

重起ssh服务,修改端口才生效

  1. [root@linux ~]# service sshd restart
  2. Stopping sshd: [ OK ]
  3. Starting sshd: [ OK ]
  4. [root@linux ~]#

注意修改端口,记得添加防火墙

  1. [root@linux ~]# firewall-cmd --zone=public --add-port=10008/tcp --permanent
  2. [root@linux ~]# firewall-cmd --reload

此文章对您是否有帮助?

« 返回