0

I have a simple Docker container for a purposeful sshd server whose image derives from alpine:latest. It currently uses /usr/sbin/sshd -D -e -ddd as its entrypoint. When I ssh into it for running a certain command remotely, that command executes alright, but then sshd and hence the container immediately shut down.

Elsewhere there is a recommendation titled "SSH login fix. Otherwise user is kicked off after login" in terms of enabling session optional pam_loginuid.so in /etc/pam.d/sshd. This sounds promising, but Alpine's sshd (from apk add openssh) apparently comes without PAM, plus I am not sure how this would function.

Can somebody please enlighten me as to how sshd inside an Alpine-based container can be made to persist across many SSH sessions in order to support normal operation?

UPDATE Here are the last few lines of sshd's log output before it shuts down:

Received disconnect from 1.2.3.4 port 29213:11: disconnected by user
Disconnected from user rts 1.2.3.4 port 29213
debug1: do_cleanup
debug3: mm_request_receive entering
debug1: do_cleanup
rookie099
  • 375
  • 3
  • 14
  • Why is it shutting down? Did you actually go and check the logs? – Michael Hampton Aug 04 '20 at 11:30
  • @MichaelHampton Of course I checked the logs. They are apparently silent about a specific reason. I'll add the last few lines to my question. Is there anything special to look out for in them? – rookie099 Aug 04 '20 at 11:37

1 Answers1

4

You're seeing this behaviour because of the -d flag. From the sshd's man page:

-d' Debug mode. The server sends verbose debug output to the system log, and does not put itself in the background. The server also will not fork and will only process one connection. This option is only intended for debugging for the server. Multiple -d options increase the debugging level. Maximum is 3.