linux修改ssh默认端口

1 . 登录服务器,打开sshd_config文件

vim /etc/ssh/sshd_config

2 . 找到#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
Port 10022
.....

3 . 重启SSH服务,最好也重启下服务器

3 .systemctl restart sshd

4 . 尝试通过10022端口登录SSH,或者进入该服务器直接本地访问SSH如下:

[root@centos7 ~]#ssh root@localhost -p 10022

 

posted @ 2023-03-03 21:03  QQmini  阅读(169)  评论(0编辑  收藏  举报