我有以下问题SSH“连接被拒绝”。它将正常工作,但是当我使用SSH时,会出现“连接被拒绝”的情况,必须重新连接(5-10分钟内不会发生)。我已经尝试了所有方法(重新启动linux,重新启动ssh),但仍然无济于事。我也检查了var / log,但那里没有任何帮助...
注意:我发现有趣的注释是,当我尝试ssh到我的外部ip(277 ...)时,它进入黑色cmd屏幕,我关闭它并尝试我的192.168.0.13地址,它允许我登录..但很短同时,再次拒绝连接...当然,如果我打开服务器并重新启动sudo sshd,我的SSH“拒绝连接”就会消失...
我的ssh端口在23打开,我也在调制解调器/路由器上进行了设置
sudpi@raspberrypi:~$ sudo netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1817/apache2
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2227/vsftpd
tcp 0 0 127.0.0.1:3350 0.0.0.0:* LISTEN 1784/xrdp-sesman
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 3115/sshd
tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN 1781/xrdp
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2397/mysqld
当我断开连接并重新登录并检查“ WHO”时,我只会看到我以前的连接,我的根和当前连接
whopi@raspberrypi:~$ who
pi tty1 2013-01-28 09:20
pi pts/0 2013-01-28 10:28 (192.168.0.12)
pi pts/1 2013-01-28 10:32 (192.168.0.12)
这就是我修改过的ssh_config中的内容(SSH到23,因为行家使用22 ...)
# Port 23
...
#Keep my damn connection alive!
KeepAlive yes
ServerAliveInterval 60
这是我运行arp-scan时得到的
pi@raspberrypi:/etc$ sudo arp-scan -I eth0 -l | grep 192.168.0.13
192.168.0.13 a0:6c:ec:ec:bb:5b (Unknown)
我在网上找到的这部分告诉我应该发布以下两个信息
pi@raspberrypi:~$ ps afxu | grep sshd
root 2838 0.0 0.7 9800 3168 ? Ss 10:27 0:00 sshd: pi [priv]
pi 2845 0.0 0.3 9800 1628 ? S 10:28 0:00 \_ sshd: pi@pt s/0
root 2854 0.0 0.7 9800 3168 ? Ss 10:32 0:00 sshd: pi [priv]
pi 2861 0.0 0.3 9800 1628 ? S 10:32 0:00 \_ sshd: pi@pt s/1
root 2900 0.3 0.7 9800 3168 ? Ss 10:44 0:00 sshd: pi [priv]
pi 2907 0.0 0.3 9800 1628 ? S 10:44 0:00 \_ sshd: pi@pt s/2
root 2934 0.0 0.2 6204 1060 ? Ss 10:45 0:00 /usr/sbin/sshd
root 2954 0.7 0.7 9800 3164 ? Ss 10:45 0:00 \_ sshd: pi [p riv]
pi 2961 0.1 0.3 9800 1624 ? S 10:46 0:00 \_ sshd: p i@pts/3
pi 2970 0.0 0.1 3536 796 pts/3 S+ 10:46 0:00 \_ grep sshd
编辑: pi @ raspberrypi:〜$ ssh -vvv 192.168.0.13(这可能很长...谢谢Bart Friederichs)
pi@raspberrypi:~$ ssh -vvv 192.168.0.13 -p 23
OpenSSH_6.0p1 Debian-3, OpenSSL 1.0.1c 10 May 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 192.168.0.13 [192.168.0.13] port 23.
debug1: Connection established.
debug1: SELinux support disabled
...
debug1: match: OpenSSH_6.0p1 Debian-3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-3
debug2: fd 3 setting O_NONBLOCK
debug3: put_host_port: [192.168.0.13]:23
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
...
debug1: Next authentication method: publickey
debug1: Trying private key: /var/www/.ssh/id_rsa
debug3: no such identity: /var/www/.ssh/id_rsa
debug1: Trying private key: /var/www/.ssh/id_dsa
debug3: no such identity: /var/www/.ssh/id_dsa
debug1: Trying private key: /var/www/.ssh/id_ecdsa
debug3: no such identity: /var/www/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
pi@192.168.0.13's password: - I TYPED PASSWORD -
...
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Linux raspberrypi 3.6.11+ #350 PREEMPT Mon Jan 7 21:51:11 GMT 2013 armv6l
netstat -tlpn
以root身份运行(或使用sudo
)。如果您不太熟悉Linux管理,从默认端口移动SSH似乎不是一个好主意。