Linux VPS服务器SSH端口一键修改脚本

方法

系统要求:支持DebianUbuntuCentOS系统。 运行以下命令:

<span class="hljs-attribute">wget</span> https://www.moerats.com/usr/down/sshport.sh
bash sshport.sh

输入端口确认。再打开防火墙端口:

<span class="hljs-comment">#如果防火墙使用的iptables(Centos 6),修改端口为8080</span>
<span class="hljs-attribute">iptables</span> -I INPUT -p tcp --dport <span class="hljs-number">8080</span> -j ACCEPT
service iptables save
service iptables restart
<span class="hljs-comment">#如果使用的是firewall(CentOS 7)</span>
firewall-cmd --zone=public --add-port=<span class="hljs-number">8080</span>/tcp --<span class="hljs-literal">permanent</span> 
firewall-cmd --reload

最后重启ssh生效:

<span class="hljs-meta">#</span><span class="bash">CentOS系统</span>
service sshd restart
<span class="hljs-meta">#</span><span class="bash">Debian/Ubuntu系统</span>
service ssh restart

原文链接: https://www.moerats.com/archives/394/
Tagged on: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.