Docker Community Forums

Share and learn in the Docker community.

How to install ssh on container?


(Julianonunes) #1

I need to allow SSH access to a container using Ruby image, how can I do this? It’s only for my development environment (I’ll set Jetbrains RubyMine to use the Ruby SDK on a running container instead of installing it in my Windows PC).

(David Maze) #2

Generally you don’t; you use docker exec to get a shell in a running container.

(Julianonunes) #3

I don’t need a shell, I need to provide an IP and PORT to RubyMine so it can connect to the container.

(Rusher81572) #4

Here is my Dockerfile how I did it so I can use Hadoop:

FROM ubuntu
USER root
RUN apt-get update;apt-get install -y openjdk-8-jdk-headless wget openssh-server tar vim

RUN echo “root:training” | chpasswd
RUN sed -i ‘s/prohibit-password/yes/’ /etc/ssh/sshd_config
ADD ssh.tar /root/
RUN chown -R root:root /root/.ssh;chmod -R 700 /root/.ssh
RUN echo “StrictHostKeyChecking=no” >> /etc/ssh/ssh_config
RUN mkdir /var/run/sshd


EXPOSE 22 8088 50070
CMD bash /

(Julianonunes) #5

Where can I get the ssh.tar and files?

(Rusher81572) #6

Those are optional…I added my personal ssh keys there so I do not have to enter a password

(Pushpabuzz) #7
  • echo “root:root”
  • chpasswd
    chpasswd: (user “root) pam_chauthtok() failed, error:
    Authentication token manipulation error
    chpasswd: (line 1, user “root) password not changed