SSH 服务器拒绝来自同一客户端的多个连接

SSH 服务器拒绝来自同一客户端的多个连接

我有一个简单的 openssh 服务器在 Alpine Linux 3.15 Docker 容器中运行,另一个容器也运行与 SSH 服务器相同版本的 Alpine),该容器运行带有 dwm 的 X 服务器

st使用以下命令从 X 服务器连接到 SSH 服务器(并运行):

ssh -v -t [email protected] st

SSH 服务器正在使用以下命令执行:

/usr/bin/sshd -D -d -e

变量$DISPLAY设置为ssh:10ssh作为 SSH 服务器主机名)

客户端能够st通过 X11 从服务器转发到客户端显示来打开图形应用程序( ),问题是我只能打开一个实例,st然后收到以下错误:

ssh: connect to host 172.17.0.2 port 22: Connection refused

服务器端日志:

Starting session: command on pts/1 for client from 172.17.0.3 port 34060 id 0
debug1: Setting controlling tty using TIOCSCTTY.
debug1: X11 connection requested.
debug1: channel 3: new [X11 connection from 172.17.0.2 port 35028]
debug1: Received SIGCHLD.
debug1: session_by_pid: pid 9
debug1: session_exit_message: session 0 channel 0 pid 9
debug1: session_exit_message: release channel 0
debug1: session_by_tty: session 0 tty /dev/pts/1
debug1: session_pty_cleanup2: session 0 release /dev/pts/1
debug1: channel 3: free: X11 connection from 172.17.0.2 port 35028, nchannels 4
debug1: session_by_channel: session 0 channel 0
debug1: session_close_by_channel: channel 0 child 0
debug1: session_close_x11: detach x11 channel 1
debug1: session_close_x11: detach x11 channel 2
Close session: user client from 172.17.0.3 port 34060 id 0
debug1: channel 0: free: server-session, nchannels 3
debug1: channel 1: free: X11 inet listener, nchannels 2
debug1: channel 2: free: X11 inet listener, nchannels 1
Received disconnect from 172.17.0.3 port 34060:11: disconnected by user
Disconnected from user client 172.17.0.3 port 34060
debug1: do_cleanup
debug1: do_cleanup

客户端日志:

Running /usr/bin/xauth remove ssh:10.0
/usr/bin/xauth add ssh:10.0 MIT-MAGIC-COOKIE-1 49907415ff518044198f6f0075f270fe
debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384
debug1: client_request_x11: request from 172.17.0.2 35028
debug1: channel 1: new [x11]
debug1: confirm x11
OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 172.17.0.2 [172.17.0.2] port 22.
debug1: connect to address 172.17.0.2 port 22: Connection refused
ssh: connect to host 172.17.0.2 port 22: Connection refused
xinit: connection to X server lost

waiting for X server to shut down debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 1: free: x11, nchannels 2
X connection to ssh:10.0 broken (explicit kill or server shutdown).
debug1: channel 0: free: client-session, nchannels 1
Connection to 172.17.0.2 closed.
Transferred: sent 91292, received 92728 bytes, in 3.1 seconds
Bytes per second: sent 29350.8, received 29812.5
debug1: Exit status 1
(II) Server terminated successfully (0). Closing log file.

deallocvt: can't open console

答案1

你说你正在sshd使用这个命令运行:

/usr/bin/sshd -D -d -e 

“-d”选项用于调试。它有这样的效果:

调试模式。服务器将详细的调试输出发送到标准错误,并且不会将其自身置于后台。服务器也不会 fork(2) 和只会处理一个连接。该选项仅用于服务器调试。多个 -d 选项可提高调试级别。最大值为 3。

您所描述的行为(其中 sshd 仅接受一个连接,然后不再接受更多连接)正是您期望在“-d”选项生效时看到的行为。

如果您想获得与现在相同的行为,仅sshd处理多个连接,则应该这样做:

/usr/bin/sshd -D -e -o LogLevel=DEBUG1

相关内容