Ubuntu 上的 SSH 问题 - 本地连接正常,远程连接 - 是我还是我的 ISP 的问题?

Ubuntu 上的 SSH 问题 - 本地连接正常,远程连接 - 是我还是我的 ISP 的问题?

我在运行 Ubuntu 12.04 的服务器上遇到了问题,我试图设置远程连接,以便可以从城外访问我工作的服务器。我已经安装了 SSH 服务器和所有这些东西,并且我已将默认端口从 22 重新分配给 3399。

任何操作系统的本地连接都可以连接到 192.168... 地址,但我无法通过实际 IP 地址建立连接。

我相信我的配置是正确的,我会附上它。如果我在配置中做错了什么,请告诉我,我会做出改变。

说实话,我认为我的 ISP 提供的路由器很糟糕,尽管 ssh 的端口已转发,但它可能会阻止任何入站流量。我可以尝试什么来验证这一点?当我通过我们的静态 IP 连接时,/var/log/auth 没有显示任何错误。我已将以下未注释掉的所有值都包括在内:(sshd_config)

Port 3399

ListenAddress 0.0.0.0
Protocol 2

HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
UseDNS no
RSAAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
PasswordAuthentication yes
GSSAPIAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes

我做错了吗?

端口转发图像

编辑:有没有办法检查连接是否到达服务器?我运行 ssh -vvv 到我的 IP,它说它加载了我的本地 ssh 配置,我需要配置它吗?下面是 v

OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 204.191.22.127 [204.191.22.127] port 3399.
debug1: connect to address 204.191.22.127 port 3399: Connection refused

以下是 ssh -vvv 到我的本地 192.168 服务器的结果

答案1

在路由器上,确保将外部 IP 上的端口 3399 转发到内部 IP 上的端口 3399。如果它不允许您指定端口号,那么您必须将 sshd 配置改回在端口 22 上运行,并将路由器设置为转发到该端口。

您的 sshd 配置看起来不错。我建议您创建一个具有完全 sudo 访问权限的普通用户帐户,然后更改允许Root登录在您的 sshd 配置中并重新启动 sshd 服务。然后使用您的常规用户帐户 ssh 进入服务器并使用 sudo 进行管理。

相关内容