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

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threatpost
GbyAI
GbyAI
V
Visual Studio Blog
H
Help Net Security
Vercel News
Vercel News
P
Palo Alto Networks Blog
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Latest news
Latest news
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
The Register - Security
The Register - Security
博客园_首页
WordPress大学
WordPress大学
G
GRAHAM CLULEY
T
Tor Project blog
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
O
OpenAI News
博客园 - 聂微东
月光博客
月光博客
S
Security Affairs
Webroot Blog
Webroot Blog
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
N
News and Events Feed by Topic
Blog — PlanetScale
Blog — PlanetScale
S
Securelist
V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
阮一峰的网络日志
阮一峰的网络日志
Stack Overflow Blog
Stack Overflow Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
DataBreaches.Net
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
Cisco Talos Blog
Cisco Talos Blog
The Cloudflare Blog
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
L
Lohrmann on Cybersecurity
T
The Blog of Author Tim Ferriss

噜啦 - linux

CentOS 6 安装 htop nload Linux脚本报错syntax error near unexpected token '$'\r'' CentOS 6、7 一键更换内核安装锐速 - 噜啦 Centos 添加用户并授予root权限 - 噜啦
Centos 修改SSH端口为其他端口 - 噜啦
博主: 噜啦 · 2019-02-09 · via 噜啦 - linux
  • 发布时间:
  • 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端口为其他端口

 •