I try to deploy debian containers to allow users to connect to them over SSH (for students for exemple).
I managed to do this but when I am connected to the container I have a pseudo-TTY and it's not the expected result I want. I want to have a complete interactive shell like when we connect to a reel server or machine.
I tried several ideas like :
change the docker add options in my
docker run
commands like :docker run -d -it CONAINER_ID
change the
sshd_config
in the debian container to allow TTYchange my dockerfile many times
add
ssh
options when I connect :ssh -t
orssh -tt
But any of theses ideas seems to help me. I show you my current Dockerfile it can be helpfull.
FROM debian:latest
RUN apt-get update && apt-get install -y openssh-server && apt-get install -y sudo nano
RUN mkdir /var/run/sshd
RUN service ssh start
RUN useradd -m john && echo "john:john" | chpasswd && adduser john sudo
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
So can any one tell me if I can change or do something to resolve this problem please ? Thanks
CodePudding user response:
When you do the docker run command is there an option to map the local port (say 8212 to the container's port 22?
Typically, even when you expose an http or https port you have to provide a mapping:
$ docker run -d -p 81:80 --name httpd-container httpd
So I think you would need to map a port to be able to access the one in the local container.
CodePudding user response:
I solved this problem with adding just one option in my Dockerfile when I create the user :
RUN useradd -ms /bin/bash john && echo "john:john" | chpasswd && adduser john sudo
Now, when I log into the container with SSH, I have a fully complete SHELL.