惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

噜啦 - ssh

SSH SCP使用方法 - 噜啦
Centos 修改SSH端口为其他端口 - 噜啦
博主: 噜啦 · 2019-02-09 · via 噜啦 - ssh
  • 发布时间:
  • 1925 次浏览
  • 1354字数
  • 分类: Linux笔记本
  1. 首页
  2. 正文  

使用默认的22端口很不安全,这里记录一下Centos 修改默认22端口为其他端口的教程


vi /etc/ssh/sshd_config

找到字段:

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

将注释符#去掉(防止修改端口后无法连接服务器)

在这行下面按照格式增加同一行,例如:

Port 1234

修改后是这样子的:

Port 22
Port 1234
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

保存后,重启sshd服务

etc/init.d/sshd restart 

或者

service sshd restart

配置完毕,测试刚才设置的端口(1234)是否可以连接ssh,如果不行,可能是防火墙没有打开

方法一:
关闭防火墙(iptables)

/etc/init.d/iptables stop

或者

service iptables stop

方法二:
开放1234端口

vi /etc/sysconfig/iptables

新增一条策略,放通端口1234:

:INPUT ACCEPT [0:0]

    :FORWARD ACCEPT [0:0]

    :OUTPUT ACCEPT [0:0]

    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

    -A INPUT -p icmp -j ACCEPT

    -A INPUT -i lo -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 1234 -j ACCEPT

    -A INPUT -j REJECT --reject-with icmp-host-prohibited

    -A FORWARD -j REJECT --reject-with icmp-host-prohibited

    COMMIT

测试端口完成后,就可以注释掉/etc/ssh/sshd_config中的22端口了

赞赏作者

如果觉得我的文章对你有用,请随意赞赏

Centos 修改SSH端口为其他端口

 •