Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Putty 連線 CentOS 虛擬機出現 Connection refused 完整排除流程

編輯:Linux 教學

新裝 CentOS 虛擬機,Putty 連線提示 Network error: Connection refused,但 ping 正常。原因通常是 sshd 未安裝/未啟動或防火牆封鎖 22 埠。

排除步驟

  1. 確認 sshd 服務
    ssh localhost
    若提示 Connection refused 表示服務未啟動。
  2. 安裝 openssh-server
    yum install openssh-server
  3. 啟動服務
    /etc/init.d/sshd start (CentOS 6)
    systemctl start sshd (CentOS 7/8)
  4. 開放防火牆 22 埠
    CentOS 6:iptables -I INPUT -p tcp --dport 22 -j ACCEPT && service iptables save
    CentOS 7/8:firewall-cmd --permanent --add-port=22/tcp && firewall-cmd --reload
    或暫時關閉防火牆測試:service iptables stop / systemctl stop firewalld
  5. 設定開機自啟
    chkconfig sshd on / systemctl enable sshd

驗證

Putty 輸入虛擬機 IP,連線成功出現 login as: 提示即表示修復完成。

注意

  • 所有操作需在 root 權限 下執行。
  • 若為雲端主機,另需檢查安全群組/防火牆規則是否開放 22 埠。

依序執行上述步驟,即可解決 99% 的 Connection refused 問題。

Copyright © Windows教程網 All Rights Reserved