Linux修改ssh默认端口22

:2018-10-04    :218 次   :1092 字   

1.环境介绍

*系统是centos7-64bit
*vps是vultr的kvm框架
*默认工具使用xsehll
*vps所有端口已经开启,防火墙关闭
 

2.修改过程

2.1先使用22端口登录vps

Connecting to ****.**3*.*:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last failed login: Thu Oct  4 05:07:59 UTC 2018 from 22.**.***.** on ssh:notty
There were 7 failed login attempts since the last successful login.
Last login: Thu Oct  4 04:54:09 2018 from **.**.**.**12
[root@ssr ~]#


2.2 输入代码

[root@ssr ~]# vi /etc/ssh/sshd_config


2.3 查看文件,发现#Port 22 有个#号

# 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 ::


2.4 输入I进入insert状态修改为:

# 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
Port 233  #233是你的端口
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::


2.5 输入:wq保存退出

2.6 关闭SELinux

setenforce 0


2.7 启用端口

systemctl restart sshd  
shutdown -r now  
reboot


3.修改完成




    暂无评论,快来抢沙发吧!
×