linux – 为什么ssh连接无法连接整个正确的设置?
使用Ubuntu Server 14.04我在端口2222上运行了ssh服务器(他们在构建时就这样问了).我已经对整个设置进行了审核,似乎没有任何问题.
这是设置的: >在构建时,它们将端口2222上的tcp连接重定向到我的IP. 2222 / TCP ALLOW Anywhere 因此,每当我尝试连接时,我都会收到如下消息: ssh: connect to host <publicbuildingip> port 2222: Connection refused 以详细模式运行客户端输出: debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to <publicip> [<publicip>] port 2222. debug1: connect to address <publicip> port 2222: Connection refused ssh: connect to host <publicip> port 2222: Connection refused 如果我尝试从同一网络的主机登录,也会发生同样的情况. 在服务器上运行netstat,如sudo netstat -tulpn | grep ssh输出: tcp 0 0 127.0.0.1:2222 0.0.0.0:* LISTEN 969/sshd 从网络外部对公共IP运行nmap输出: Host is up (0.051s latency). Not shown: 996 filtered ports PORT STATE SERVICE 21/tcp closed ftp 80/tcp open http 2222/tcp closed unknown 8080/tcp closed http-proxy Nmap done: 1 IP address (1 host up) scanned in 5.31 seconds 尝试使用telnet< publicip> 2222 输出: telnet: Unable to connect to remote host: Connection refused 如果在建筑物内部使用网络ip尝试也一样. 但是iftop在服务器上运行时显示,尝试登录时实际上是网络活动. 在服务器上运行tcpdump,如:tcpdump -vniay port 2222 -i eth0将在登录尝试时输出: 15:53:36.812402 IP (tos 0x0,ttl 64,id 56954,offset 0,flags [DF],proto TCP (6),length 60) 192.168.1.86.39822 > 192.168.1.90.2222: Flags [S],cksum 0xa1b8 (correct),seq 3966921350,win 292000,options [mss 1460,sackOK,TS val 308476 ecr 0,nop,wscale 7],lenght 0 它会失败的是什么? 解决方法
基于该netstat输出和您的sshd配置文件(尤其是
this line),您的SSH守护程序正在侦听仅本地IP地址(127.0.0.1),而不是实际与LAN通信或通过路由器/网关出站的IP网络上的设备.
验证您的sshd_config是否设置为LAN上的ListenAddress行,例如分配给服务器的专用LAN IP地址.如果没有,请在port指令之后添加,使用ListenAddress 0.0.0.0或ListenAddress ::等语法,用实际的IPv4或IPv6地址替换这些项目. 请记住,绑定到127.0.0.0/8中的任何IP地址只会在本地计算机本身,而不是任何可以实际路由到LAN /本地网络/其他任何地方的地址. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |