My problem is almost exactly the same as the following link, except my ssh server is in a docker container.
My Dockerfile is very simple.
FROM ubuntu:12.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y openssh-server less nano
RUN mkdir /var/run/sshd
RUN adduser chrome
RUN echo "chrome:chrome" | chpasswd
RUN echo "root:chrome" | chpasswd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
When I try to ssh login, it hangs forever starting the shell.
$ ssh -p2222 chrome@localhost /bin/bash --noprofile --norc # trying to login with ssh
chrome@localhost's password: <-------------hangs forever
I can login if I use the -t
argument on ssh. I don't know why.
Running other programs like ls
works without problems. Perhaps someone can replicate this container and figure out what the problem is?
Best Answer
This is nothing to do with docker, you can get the same thing to happen when you ssh to a remote host.
A clue to the problem is in the ssh man page
So, ssh doesn't use a tty allocation if you provide a remote command to be run unless you use the
-t
switch. As bash is interactive it requires a tty.