无法通过 SSH 连接到家用计算机

Can't SSH into a home computer

我正在尝试通过 SSH 从我的 MacOSX 计算机连接到 Ubuntu 计算机。我在 Ubuntu 上安装了 openssh 并禁用了防火墙。我之前在这台 Macbook 上通过 ssh 访问过其他服务器。我没有收到来自 Ubuntu 服务器的响应:

$ ssh -v <domain_name>
OpenSSH_7.8p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to <domain_name> port 22.
ssh: connect to host <domain_name> port 22: Operation timed out

我已经尝试 ping 域名,有效。我在 Ubuntu 电脑上 运行 'ssh localhost' 并且运行良好。我还检查了端口 22 是否正在侦听并且是 ssh,它是。我尝试使用 'ssh username@domain_name'。同样的回应。有什么想法吗?

正如提问者的评论所指出的,目标计算机的 IP 是一个子网 IP,这表明该目标位于某些设备之后,例如路由器或类似设备。

然后,pinging到domain_name,从路由器,会被定位到那个路由器,但是你可能不知道这个.

要解决此问题,只需在路由器上配置一个端口转发,"when receiving data from <outer port>, forward it to <inner ip>:<inner port>",然后 ssh 请求将被转发到预期的目的地。