浅谈修改ssh端口

  • 查看ssh端口信息和防火墙信息
[root@linux01 ~]# netstat -lntp|grep ssh
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      846/sshd            
tcp6       0      0 :::22                   :::*                    LISTEN      846/sshd        
[root@linux01 ~]# getenforce    #关闭防火墙进入/etc/selinux/config配置文件设置Disabled即可
Disabled
  • ssh端口修改存放的配置文件
[root@linux01 ~]# vi /etc/ssh/sshd_config
#       $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 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:/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    <----先把#取消掉,为防止端口修改失败作备用,修改成功后再注释即可
Port xxx     <----添加这一条参数,表示你要修改的端口参数
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
.........
  • 重启sshd服务
[root@linux01 ~]# service sshd restart
  • 测试端口修改,xshell终端工具下修改session端口值,重新打开测试连通性
[root@linux01 ~]# netstat -lntp|grep ssh    #执行该命令检测是否存在22和修改的端口值参数
  • 以上步骤成功后,进入/etc/ssh/sshd_config配置文件注释22端口信息即可
  • 修改/etc/services文件(标准端口配置文件,有些服务启动会去查找这文件登记的信息)
[root@linux01 ~]# cat /etc/services
......
ssh             22/tcp                          # The Secure Shell (SSH) Protocol    #把这里的端口值替换成修改的值即可
ssh             22/udp                          # The Secure Shell (SSH) Protocol
......

转载于:https://my.oschina.net/u/3119180/blog/1576463

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值