您现在的位置是: 首页 > 运维 Linux 修改默认的 ssh 22 端口
Linux 修改默认的 ssh 22 端口
2020-05-20 【运维】 2850人已围观 4764次浏览
简介Linux 修改默认的 ssh 22 端口
首先是编辑 ssh 的配置文件
vim /etc/ssh/sshd_config
找到下面的信息
#Port=22
删除最前面的 # ,并在下面新增一行
Port=22
Port=你想自定义的端口,比如52200
保存退出,然后重启 ssh 服务
systemctl restart sshd.server
或者
/etc/init.d/sshd restart
或者
service sshd restart
这几条命令都可以重启 ssh 服务
这时候会发现 ssh 服务同时运行在 22 和 52200 端口上,可以通过
netstat -ntlp
查看端口信息
PS:这里之所以要打开22端口的注释,是防止重启ssh服务之后,当前的会话中断,并且因为没有打开 52200 端口的防火墙规则,导致无法正常连接
设置好防火墙
firewall-cmd --permanent --zone=public --add-port=52200/tcp
重载配置文件
firewall-cmd --reload
具体的防火墙规则添加请参考自己的操作系统
之后退出,使用新修改的端口连接 ssh
ssh -p 52200 root@xxx
如果可以正常登录,则修改成功,这时候可以重新修改 ssh 配置文件,注释默认的 22 端口,并重启 ssh 服务,这时候会发现ssh服务只运行在52200端口上,之前的22端口已经释放,之后再添加防火墙规则禁止 22 端口即可
很赞哦! (0)
相关文章
- Redis 提示 MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk 解决方案
- Linux no space left on device 出现设备上没有空间问题
- 自建Ngrok服务端
- Linux 查看磁盘、磁盘分区、挂载磁盘、卸载磁盘操作
- CentOS 7 安装 Golang 环境
- Docker 批量操作命令
- Linux 服务器之间传输大文件(压缩文件、查看MD5、后台传输)
- 【Docker】unauthorized: incorrect username or password
- nginx 出现 the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in 错误解决方案
- docker mysql 导入 SQL 脚本
点击排行
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- Debian apt 使用国内镜像
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- SpringBoot @NotBlank 不生效问题
- 记一次 Mybatis-Plus 自动填充无效问题解决
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
- nuxt 项目完整部署方案
站长推荐
猜你喜欢
- CentOS 安装JDK
- nginx 出现 the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in 错误解决方案
- sentinel directive while not in sentinel mode 问题解决
- 解决Mac突然没声音的问题
- Linux 安装 Tengine
- start.spring.io访问太慢,构建SpringBoot项目失败
- 使用 OpenSSL 将 pfx 格式证书转为 pem 格式
- Nginx转发阿里云OSS内网流量
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- 优化 Mac 上 office 软件更新慢的问题