1

I have a situation where in I need to start two docker containers from the same core OS. Both the docker containers must run a ssh server. I expose different ports when I run these container.

For example, Container 1, 9998:22 will expose 9998 and container 2, 9999:22 will expose 9999.

I use the following command to set the password for root in both these container (using dockerfile),

RUN echo 'root:test' |chpasswd.

When I ssh root@IP -p 9998 and use test as password am able to get into that docker container. However, when I ssh root@IP -p 9999 and use the same password I can't. I get permission denied.

Any clues?

Karthik
  • 315
  • 1
  • 4
  • 17
  • 1
    I wonder how you are able to login as `root` into your first container in the first place since usually this is not allowed in `/etc/ssh/sshd_config`. Could you try setting up a `user` in your `Dockerfile` and try to log into both containers again? You can set up the user as follows AFTER you set up root and all the things you want to install: `RUN useradd -m user1095279`, `RUN echo "user1095279:test" | chpasswd`, `RUN usermod -s /bin/bash user1095279`, `RUN usermod -aG sudo user1095279`, `ENV HOME /home/user1095279`, `ENV HOSTNAME user1095279box`. – lord.garbage Sep 02 '14 at 09:53
  • 1
    Thanks for the comment. I figured out the issue was due to the version of the open ssh server. The one in container 2 was the latest and when I downgraded, I can login to both. But your answer seems to be the right way of logging in. – Karthik Sep 03 '14 at 10:02
  • If you just use `ssh` because of `X11` forwarding but have your container on the same machine you might be very interested in this: http://stackoverflow.com/questions/25281992/alternatives-to-ssh-x11-forwarding-for-docker-containers. – lord.garbage Sep 03 '14 at 10:49

0 Answers0