[英]Can't ssh to docker(ubuntu:19.04) because of happen permission denied
I made ssh service docker from this Dockerfile.我从这个 Dockerfile 制作了 ssh 服务 docker。
FROM ubuntu:19.04
RUN apt-get update && apt-get install -y openssh-server \
postgresql-client \
language-pack-ja
RUN update-locale LANG=ja_JP.UTF-8
RUN mkdir /var/run/sshd
ARG ROOT_PASSWORD
RUN echo root:${ROOT_PASSWORD} | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
I followed this page.我关注了这个页面。
https://docs.docker.com/engine/examples/running_ssh_service/https://docs.docker.com/engine/examples/running_ssh_service/
It is differently that only changed ubuntu image version to 19.04.不同的是,仅将 ubuntu 映像版本更改为 19.04。
However, I couldn't ssh as happened permission denid.但是,由于权限被拒绝,我无法 ssh。
docker build --build-arg ROOT_PASSWORD=$ROOT_PASSWORD -t eg_sshd .
docker run -d -P --name test_sshd eg_sshd
docker port test_sshd 22
0.0.0.0:32770
ssh root@localhost -p 32770
root@localhost's password:
Permission denied, please try again.
Why did It happen permission denied?为什么它发生权限被拒绝?
The PermitRootLogin line was not comment out when it was 16.04, however comment out when it was 18.04, so I set it to #\\?
PermitRootLogin 行在 16.04 时没有注释掉,但是在 18.04 时注释掉,所以我将它设置为
#\\?
in order to accommodate both.为了兼顾两者。
It could execut from following Dockerfile.它可以从以下 Dockerfile 执行。
FROM ubuntu:19.10
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
RUN sed -i 's/#\?PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.