You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Mac连接Hostinger VPS时遇SSH超时错误求助

解决SSH连接Hostinger VPS超时(Operation timed out)的问题

基础连通性排查

  • 测试VPS IP是否可达:
    ping xxxxxxxxxx
    
    若ping不通,说明网络层面存在阻断,直接跳至网络限制排查环节;若能ping通,继续下一步。
  • 测试22端口是否开放:
    telnet xxxxxxxxxx 22
    
    连接失败则说明端口被拦截或VPS未监听22端口。

VPS端SSH配置与服务检查

通过Hostinger的hPanel网页端终端操作:

  • 确认SSH服务状态:
    systemctl status sshd
    
    未启动则执行:
    systemctl start sshd
    systemctl enable sshd
    
  • 检查SSH配置文件/etc/ssh/sshd_config:
    确保以下参数设置正确:
    Port 22  # 若自定义了端口,后续连接需加-p指定
    PermitRootLogin yes  # 用root登录时需开启,密钥登录可设为prohibit-password
    ListenAddress 0.0.0.0  # 监听所有IP地址
    
    修改后重启服务:
    systemctl restart sshd
    
  • 放行VPS防火墙22端口:
    • 用ufw的情况:
      ufw allow 22/tcp
      ufw reload
      
    • 用firewalld的情况:
      firewall-cmd --add-port=22/tcp --permanent
      firewall-cmd --reload
      

网络限制排查

  • 检查本地Mac防火墙:打开「系统设置-网络-防火墙」,确认未拦截SSH(22端口)出站请求。
  • 切换网络环境:比如用手机热点替代当前WiFi,排除本地运营商端口屏蔽。
  • 检查Hostinger面板防火墙:在VPS管理模块的「防火墙」选项中,确认已添加22端口的入站放行规则。
  • 确认VPS IP状态:联系Hostinger客服核实IP是否被加入黑名单或存在网络异常。

替代连接方案

  • 更换SSH端口:若22端口被阻断,在hPanel修改端口(如2222)后,用以下命令连接:
    ssh root@xxxxxxxxxxx -p 2222
    
  • 密钥登录替代密码:
    1. 本地生成密钥对:
      ssh-keygen -t ed25519
      
    2. 将公钥上传至VPS的/root/.ssh/authorized_keys文件,再执行原连接命令。

内容的提问来源于stack exchange,提问作者Awara Amini

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 09:42:39