为什么我不能使用 ssh?

为什么我不能使用 ssh?

这个问题似乎是从我安装 Ubuntu 14.04 LTS 起就直接出现的。

当我尝试连接 HostGator 的主机时,我第一次意识到这个问题。我忽略了这一点,认为这是他们这边的问题,并继续使用他们基于网络的文件管理器。

我最近开始使用git,我无法git push在GitHub上进行远程服务器。

$ git push -u origin master
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

git 命令的输出清楚地表明问题出在我这边和 ssh 上。

为了验证问题出在我这边,我发出了更多命令:

$ ssh -v sdf.org
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to sdf.org [192.94.73.15] port 22.
^Ydebug1: connect to address 192.94.73.15 port 22: Connection timed out
ssh: connect to host sdf.org port 22: Connection timed out

$ telnet sdf.org 22
Trying 192.94.73.15...
telnet: Unable to connect to remote host: Connection timed out

PS:我仍然可以 ping 到服务器。

答案1

您和目标站点之间的某些防火墙通过阻止传出数据包或阻止响应来阻止与端口 22 的 TCP 连接。

您可以通过运行来定位防火墙tcptraceroute github.com 22

如果防火墙超出您的控制范围(例如在您的 ISP 设备上),那么如果没有外部帮助,您将无能为力。如果您的 ISP 阻止这些连接,请检查您的合同是否限制您可以执行的操作,如果您的合同不包含任何适用的限制,请联系您的 ISP。

如果无法连接到端口 22,可以使用隧道。端口 443 通常对传出连接保持开放,因为它是 HTTPS 的端口。但这意味着您在端口 443 上与外部计算机建立连接,然后它将流量转发到github.com端口 22。您需要有一台能够执行此操作的外部计算机。看如何通过 http 或 https 使用 ssh?一些配置说明。

相关内容