更新

更新

我有一台 Raspberry Pi 4,我启用了 SSH,我想从 Windows 通过 SFTP 连接到它(也尝试过从 Android 手机连接,但出现同样的问题)。在 gif 中,顶部窗口使用 SSH 连接,我在日志文件上运行了 tail。

在第二个窗口中,我运行 sftp 并尝试第一次使用错误密码登录,第二次尝试时输入了正确的密码。控制台仍然挂起。Gif 在这里

tail auth.log -f

Jan  8 19:42:28 raspberrypi sshd[10184]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.2.165  user=pi
Jan  8 19:42:30 raspberrypi sshd[10184]: Failed password for pi from 192.168.2.165 port 62685 ssh2
Jan  8 19:42:33 raspberrypi sshd[10184]: Accepted password for pi from 192.168.2.165 port 62685 ssh2
Jan  8 19:42:33 raspberrypi sshd[10184]: pam_unix(sshd:session): session opened for user pi by (uid=0)
Jan  8 19:42:33 raspberrypi systemd-logind[407]: New session c100 of user pi.
Jan  8 19:42:33 raspberrypi sftp-server[10217]: session opened for local user pi from [192.168.2.165]
Jan  8 19:42:38 raspberrypi sshd[10215]: Received disconnect from 192.168.2.165 port 62685:11: disconnected by user
Jan  8 19:42:38 raspberrypi sshd[10215]: Disconnected from user pi 192.168.2.165 port 62685
Jan  8 19:42:38 raspberrypi sftp-server[10217]: session closed for local user pi from [192.168.2.165]
Jan  8 19:42:38 raspberrypi sshd[10184]: pam_unix(sshd:session): session closed for user pi
Jan  8 19:42:38 raspberrypi systemd-logind[407]: Session c100 logged out. Waiting for processes to exit.
Jan  8 19:42:38 raspberrypi systemd-logind[407]: Removed session c100.

控制软件

看起来连接成功了,但是中途出现了一些问题。

运行 SFTP 命令从树莓派内部似乎有效。但使用 sftp 连接到本地主机并不是很有用 :)

pi@raspberrypi:/etc/ssh $ sftp pi@localhost
pi@localhost's password:
Connected to pi@localhost.
sftp> exit
pi@raspberrypi:/etc/ssh $     

运行将得到以下输出sftp -vvv [email protected]

....
[email protected]'s password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to 192.168.2.196 ([192.168.2.196]:22).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug1: Sending subsystem: sftp
debug2: channel 0: request subsystem confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768

GETS STUCK HERE

更新

这似乎是网络问题或驱动程序问题。我将 Raspberry Pi 连接到 2.4Ghz 而不是 5Ghz(PC 仍为 5ghz),并且有效

我还记录了它tcpdump -i wlan0 port 22 -n -Q inout何时工作以及何时不工作,您可以在下面看到(删除了时间戳以便于比较差异)。

WORKING:

IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 1494555936:1494556020, ack 4046582101, win 512, length 84
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 84, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 1:29, ack 84, win 272, length 28
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 84:196, ack 29, win 512, length 112
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 196, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 29:529, ack 196, win 272, length 500
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [.], ack 529, win 510, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 529:573, ack 196, win 272, length 44
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 196:248, ack 573, win 510, length 52
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 248, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 248:292, ack 645, win 510, length 44
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 645:833, ack 292, win 272, length 188
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 292:336, ack 833, win 509, length 44
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 336:380, ack 833, win 509, length 44
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 380, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 833:909, ack 380, win 272, length 76
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [.], ack 909, win 509, length 0
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 380:416, ack 909, win 509, length 36
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 909:1033, ack 416, win 272, length 124
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 416:452, ack 1033, win 508, length 36
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 452:512, ack 1033, win 508, length 60
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 512, win 272, length 0
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [R.], seq 512, ack 1033, win 0, length 0

NOT WORKING:

IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 565297912:565297996, ack 2156825212, win 512, length 84
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 84, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 1:29, ack 84, win 272, length 28
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 84:196, ack 29, win 512, length 112
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 196, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 29:529, ack 196, win 272, length 500
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [.], ack 529, win 510, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 529:573, ack 196, win 272, length 44
IP 192.168.2.244.64793 > 192.168.2.196.22: Flags [P.], seq 196:248, ack 573, win 510, length 52
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [.], ack 248, win 272, length 0
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72
IP 192.168.2.196.22 > 192.168.2.244.64793: Flags [P.], seq 573:645, ack 248, win 272, length 72

更多细节:

  • 操作系统:Raspbian 10 buster(最新,刚刚更新)

相关内容