Linux的默认登录端口是22,这种默认端口往往本身就存在一定的风险,为了加固Linux的安全性,可以通过修改SSH的默认登录端口来实现,操作比较简单,只要三步就行
1. 修改配置文件
使用命令进入配置文件编辑页面
[root@VM-4-16-centos ~]# vim /etc/ssh/sshd_config
2. 修改port
# $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 这个22是默认端口,修改的话,就放开这个注释,修改你自己想要的端口
Port 10086
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
3. 重启SSH服务
通过命令重启SSH服务
[root@VM-4-16-centos ~]# systemctl restart sshd
然后退出重新修改端口登录Linux服务即可!