如何修改ssh默认端口

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何修改ssh默认端口相关的知识,希望对你有一定的参考价值。


在使用云服务器的过程中发现有黑客通过22端口尝试硬破解root密码,为避免该安全隐患应更改ssh服务的默认端口号。

ssh的配置文件保存在/etc/ssh/sshd_config     文件中

[[email protected] ~]# vim /etc/ssh/sshd_config   文件打开后如下

#       $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm 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:/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 change a
# default value.
#Port 22     此处去掉#,并将22修改为你想使用的端口号,但修改后端口号不可与其他服务发生冲突。
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key


[[email protected] ~]# service sshd restart   修改文件后应重启服务使配置生效


本文出自 “Linux学习记录” 博客,请务必保留此出处http://zjmlinux.blog.51cto.com/4684186/1978860

以上是关于如何修改ssh默认端口的主要内容,如果未能解决你的问题,请参考以下文章

如何修改ssh默认端口

如何修改ssh默认端口

Linux修改SSH默认22端口

如何修改 ftp 端口

如何修改Linux服务器ssh端口?

如何修改Linux远程端口/如何修改ssh端口