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

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

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

 •