当您不确定Linux服务器的远程访问端口时,可以通过以下几种方法找回:
sudo cat /etc/ssh/sshd_config | grep Port
或者更详细的查看:
sudo grep -i "^Port" /etc/ssh/sshd_config
sudo netstat -tulnp | grep sshd
# 或使用ss命令
sudo ss -tulnp | grep ssh
对于iptables:
sudo iptables -L -n | grep -E '22|ssh'
对于firewalld:
sudo firewall-cmd --list-all
对于ufw:
sudo ufw status
sudo semanage port -l | grep ssh
sudo systemctl status sshd
# 或对于较旧系统
sudo service sshd status
如果确实无法确定端口,可能需要通过本地控制台访问服务器后重新配置SSH端口。