TL;DR: sed -i ‘s/session required pam_loginuid.so/session optional pam_loginuid.so/’ /etc/pam.d/sshd
I’ve previously posted (http://goo.gl/pCRkQ6) about failure SSH’ing into a Docker container running an ssh server. The prevailing fix online is to just change “UsePAM yes” to “UsePAM no” in the /etc/ssh/sshd_config file. But PAM is useful, and that’s not really a fix.
session required pam_loginuid.so
…in the /etc/pam.d/sshd file.
From man pam_loginuid:
The pam_loginuid module sets the loginuid process attribute for the process that was authenticated.
Ok, this sounds kind of useful. It’s used for application auditing. However, more Google-ing turns up that Docker explicitly drops the audit-related capabilities that are required for this to work, causing an error to be returned to PAM. (http://goo.gl/wBffo3, via this post on StackOverflow: http://goo.gl/50xOuI) This means that it’s not ever going to work in a Docker container unless the Docker code is changed. That’s out of my hands, though.
So that leaves us with the TL;DR from above. You can change “session require pam_loginuid.so” to “session optional pam_loginuid.so” in the /etc/pam.d/sshd file. This will allow you to continue to use PAM, but skip over the failure to set loginuid process attributes, and continue on with the session without bailing.
This allows the ssh session to be useful, and PAM is still around so you can use Kerberos or other PAM-related stuff inside your container.
I’m beginning to copy over my technology-related posts from Google+ to this blog, mostly so I have an easy-to-read record of them. This one was originally published on 20 May 2014: SSH In a Docker CentOS Container