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

方法

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

wget https://www.moerats.com/usr/down/sshport.sh
bash sshport.sh

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

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

最后重启ssh生效:

#CentOS系统
service sshd restart
#Debian/Ubuntu系统
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.