侧边栏壁纸
博主头像
小狐狸 博主等级

行动起来,活在当下

  • 累计撰写 34 篇文章
  • 累计创建 21 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

更改SSH端口

小狐狸
2024-07-20 / 0 评论 / 0 点赞 / 21 阅读 / 0 字 / 正在检测是否收录...

在安装openssh-server的情况下执行以下操作:

vi /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

去掉Port前面的注释更改后面端口即可

然后重启ssh服务:

systemctl restart sshd

在防火墙中放行更改的端口

firewall-cmd --zone=public --add-port=更改的端口号/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --query-port=更改的端口号/tcp

0

评论区