centos 7 已經開啟 22 埠但無法連線

2022-02-28 17:36:05 字數 539 閱讀 8787

剛買的 vps ,預設 ssh 埠是 29488, 使用以下方式連線

ssh -p 29488 [email protected]

覺得加埠有點麻煩, 希望使用預設的 22 埠。

於是開啟防火牆, 新增 22 埠, 重啟防火牆, 然後ssh [email protected]失敗, 說我 22 埠沒開啟。

幾經折騰, 原因在於:

ssh 是客戶端, sshd 是服務端, 應先看 sshd 監聽著多少埠。

所以解決方式是再去修改 sshd 監聽的埠為 22 , 然後重啟 sshd , 搞定。

firewall-cmd --zone=public --add-port=22/tcp --permanent # 新增埠

firewall-cmd --reload # 重啟防火牆

vi /etc/ssh/sshd_config # 修改埠為 port 22

/usr/sbin/sshd restart # 重啟 sshd

CentOS7開啟 關閉埠

centos7使用的是firewall防火牆,不再是原來的iptables 1 檢視firewall防火牆狀態 firewall cmd state 或者systemctl status firewalld 2 開啟防火牆 systemctl start firewalld 3 關閉防火牆 syst...

CentOS7開啟 關閉埠

centos7使用的是firewall防火牆,不再是原來的iptables 1 檢視firewall防火牆狀態 firewall cmd state 或者systemctl status firewalld 2 開啟防火牆 systemctl start firewalld 3 關閉防火牆 syst...

centos7虛擬機器開啟埠

原文 虛擬機器新開了5005埠,系統內部是顯示開了的,但是外部不能訪問埠。一些需要用到的命令 1 firewalld的基本使用 啟動 systemctl start firewalld 檢視狀態 systemctl status firewalld firewall cmd state 這個命令也可...