The connection to the ssh service running in podman container crashes

  docker, podman, ssh, ubuntu

ENV_1

os version : Ubuntu 20.04.3 LTS (Focal Fossa)
kernel version : 5.4.0-73-generic
podman version : podman version 3.2.3

First i use podman to pull a image from harbor

then i exec into the container and open ssh server by manual

the ssh port is listening

# podman pull xxx:v1
# podman run -itd -p 2201:22 xxx:v1 /sbin/init
# podman exec -it xxx:v1 /bin/bash
# /usr/sbin/sshd
# netstat -anput
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1119/sshd: /usr/sbi
tcp6       0      0 :::22                   :::*                    LISTEN      1119/sshd: /usr/sbi
# podman ps -a
CONTAINER ID  IMAGE    COMMAND           CREATED       STATUS           PORTS                                                                                                    
0ac81485cfc5  xxx:v1  /sbin/init        20 hours ago  Up 20 hours ago  0.0.0.0:2201->22/tcp                                                                                     

then i start a ssh session

# ssh [email protected] -p 2201
Connection to xxx closed.

# ssh [email protected] -p 2201 -v
OpenSSH_7.5p1, OpenSSL 1.0.2o  27 Mar 2018
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 14: Deprecated option "useroaming"
debug1: Connecting to xxxxx [xxxxx] port 2201.
debug1: Connection established.
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5
debug1: match: OpenSSH_8.4p1 Debian-5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.108.183.178:2201 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1 compression: [email protected]
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1 compression: [email protected]
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:EGFs8HOUVPX4wftZNz/qKtSfzpGxJzIo56mFS8R2KEE
debug1: Host '[xxxx]:2201' is known and matches the RSA host key.
debug1: Found key in /home/mobaxterm/.ssh/known_hosts:498
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: pubkey_prepare: ssh_fetch_identitylist: agent refused operation
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],webauthn-sk-ecdsa-sh[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (password).
Authenticated to xxxx ([xxxx]:2201).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: exec
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Requesting authentication agent forwarding.
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 0: free: client-session, nchannels 1
Connection to xxxxx closed.
Transferred: sent 2752, received 3120 bytes, in 0.3 seconds
Bytes per second: sent 8410.9, received 9535.6
debug1: Exit status 255
debug1: compress outgoing: raw data 524, compressed 356, factor 0.68
debug1: compress incoming: raw data 356, compressed 524, factor 1.47

when i use the same image in docker ,it can use ssh to connect the container

can any one know this problem ?

Source: Docker Questions

LEAVE A COMMENT