我在运行 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
Run Code Online (Sandbox Code Playgroud)
编辑:有没有办法检查连接是否甚至到达服务器?我运行 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
Run Code Online (Sandbox Code Playgroud)
在路由器上,确保将外部 IP 上的端口 3399 转发到内部 IP 上的端口 3399。如果它不允许您指定端口号,那么您必须将 sshd 配置更改回在端口 22 上运行,并设置路由器以转发到该端口。
您的 sshd 配置看起来不错。我的建议是创建一个具有完全 sudo 访问权限的常规用户帐户,然后在 sshd 配置中将PermitRootLogin更改为no并重新启动 sshd 服务。然后使用您的常规用户帐户 ssh 进入服务器并使用 sudo 进行管理。