Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] ubuntu 14.04 container with ssh login issues #5663

Closed
fruitl00p opened this issue May 7, 2014 · 14 comments
Closed

[FIXED] ubuntu 14.04 container with ssh login issues #5663

fruitl00p opened this issue May 7, 2014 · 14 comments

Comments

@fruitl00p
Copy link
Contributor

after booting a container that starts a script which in the background runs a service ssh start i'm unable to login remotely.
(the logs showing:

Accepted publickey for root from [ip adres removed] port 46953 ssh2: RSA [fingerpint adres removed]
May  8 00:42:17 231403377f9b sshd[62]: pam_loginuid(sshd:session): Cannot open /proc/self/loginuid: Read-only file system
May  8 00:42:17 231403377f9b sshd[62]: pam_loginuid(sshd:session): set_loginuid failed
May  8 00:42:17 231403377f9b sshd[62]: pam_unix(sshd:session): session opened for user root by (uid=0)
May  8 00:42:17 231403377f9b sshd[62]: pam_env(sshd:session): Unable to open env file: /etc/default/locale: No such file or directory
May  8 00:42:17 231403377f9b sshd[62]: error: PAM: pam_open_session(): Cannot make/remove an entry for the specified session
May  8 00:42:17 231403377f9b sshd[62]: Received disconnect from [ip adres removed]: 11: disconnected by user

BUT after running sed '/pam_loginuid.so/s/^/#/g' -i /etc/pam.d/* inside the container everything works.

docker info:

Containers: 3
Images: 28
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Dirs: 34
Execution Driver: native-0.2
Kernel Version: 3.13.0-24-generic
WARNING: No swap limit support

docker version:

Client version: 0.11.0
Client API version: 1.11
Go version (client): go1.2.1
Git commit (client): 15209c3
Server version: 0.11.0
Server API version: 1.11
Git commit (server): 15209c3
Go version (server): go1.2.1
Last stable version: 0.11.0

(this is based on a clean install on EC2 using the get.docker.io userdata way)
I havnt had this issue on an 0.10 docker version running via the devicemapper storage driver... Does that have anything to do with this?

@fruitl00p
Copy link
Contributor Author

Hmm... after a good nights sleep, this seems to be related to #5529

@fruitl00p
Copy link
Contributor Author

I've just restarted debugging the issue. This does seem to relate to the non writeable /proc/ for the SSH daemon.. (mentioned in #5529 )

I've now come to the conclusion that since the 0.11 (and 0.11.1) versions in order to run the SSH daemon the container itself has to be started in --privileged=true mode...

Does this have any other sideeffects? (when the app is trusted etc)

@fruitl00p fruitl00p changed the title ubuntu 14.04 container with ssh login issues [FIXED] ubuntu 14.04 container with ssh login issues May 8, 2014
@fruitl00p
Copy link
Contributor Author

After doing more searches and searches i found #5554 and from there i changed my docker file to include the SED command:

sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd

it solves the issue: i can now run service ssh start inside the container, log in using keys and it seems to work 👍

@beanjammin
Copy link

The change to /etc/pam.d/sshd worked for me. Thanks, I'd been banging my head.

@abcfy2
Copy link

abcfy2 commented May 9, 2014

Thank you. I have the same issue and it works for me.

@tianon
Copy link
Member

tianon commented May 15, 2014

@SvenDowideit wouldn't it make sense to add this sed to the "running_ssh_service" example page, and update it to explicitly use 14.04 now?

@ejo
Copy link

ejo commented May 16, 2014

+1 to @tianon's comment above... I threw many hours at this last night, even suspected pam problems at one point but others were so skeptical I looked no farther in that direction and kept chasing other leads. The example at http://docs.docker.io/examples/running_ssh_service/ really should be updated and confirmed to work for 14.04.

@andyg5000
Copy link

+1 to @fruitl00p fix

@crosbymichael
Copy link
Contributor

Fixed by #5903

@gdevillele
Copy link
Contributor

I just had this issue, but I also have it with ubuntu:13.10 container image

@fruitl00p
Copy link
Contributor Author

@Gaetan- It's not the container that's the issue, its the elevated security features in docker 0.11 before the fix of #5903 :)

@gdevillele
Copy link
Contributor

Oh! ok, thank you, I did not understand all that very well ;)
So I'll wait for next docker release!

fsouza pushed a commit to tsuru/basebuilder that referenced this issue Jun 26, 2014
@peterwillcn
Copy link

sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd

@qris
Copy link

qris commented May 30, 2016

I posted an explanation for this issue, which affects most Linux distributions as guests, but not Ubuntu >= Wily (15.10), on LXC issue 661.

openstack-gerrit pushed a commit to openstack/kolla that referenced this issue Feb 3, 2017
sshd containers don't let logins on some systems with older
PAM library because /proc/self/loginuid is not always readable
or writeable. Examples of possible failures on such systems are
erroneous cold and live migrations.

This fix does not upgrade PAM but makes pam_loginuid optional
for nova_ssh and keystone_ssh.

More information:
  moby/moby#5663
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=726661
  https://git.fedorahosted.org/cgit/linux-pam.git/tree/modules/pam_loginuid/pam_loginuid.c#n61

Change-Id: Ic14255b042ceedcff536c062bdcba00502af7a87
Closes-Bug: #1651395
felipeplets pushed a commit to felipeplets/docker-ssh-slave that referenced this issue Apr 15, 2017
I've tried to use this Docker image with AWS ECS but always got a PAM exception as suggested in this Docker issue moby/moby#5663 the sed command I just added fixed the issue of connecting via SSH to a Docker container.
CoRfr pushed a commit to CoRfr/docker-ssh-slave that referenced this issue Jun 12, 2017
I've tried to use this Docker image with AWS ECS but always got a PAM exception as suggested in this Docker issue moby/moby#5663 the sed command I just added fixed the issue of connecting via SSH to a Docker container.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants