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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

噜啦 - 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端口为其他端口

 •