I am using OpenSSH her. I can easily ssh using root@serverIP -p portNumber
, but whenever I try to ssh via a docker container user like user@@serverIP -p portNumber
it gives me permission denied.
Moreover, I have also seen the ssh service is not starting when I opt to use my user to start the container instead of the root. Please help me what am I missing here?
I am giving my dockerfile below:
P.S: I know that instead of ssh I can just use docker exec
but I have a strict condition to use ssh here. Thank you.
FROM ubuntu:16.04
MAINTAINER Mahiuddin Al Kamal <mahiuddin_al.kamal@mailbox.tu-dresden.de>
RUN apt-get update
RUN apt-get upgrade -y
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu
RUN apt-get install -y openssh-server build-essential wget make python gcc sshpass vim-tiny
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN wget -O mcperf.tar.gz https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/twemperf/mcperf-0.1.1.tar.gz
RUN mkdir mcperf && tar -xvf mcperf.tar.gz --strip-components=1 -C ./mcperf/
RUN cd /mcperf && ./configure && make && make install
RUN wget -O dude.tar.gz https://bitbucket.org/db7/dude/get/v3.1.tar.gz && mkdir dude && tar -xvf dude.tar.gz --strip-components=1 -C ./dude/
RUN cd /dude && python setup.py install
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
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
RUN sed -i 's/22/10023/' /etc/ssh/sshd_config
RUN apt-get -y install r-base
RUN echo 'screencast' > sshpass.txt && chmod 777 sshpass.txt
#sshpass -p screencast ssh -o StrictHostKeyChecking=no root@172.19.0.2
#sshpass -f sshpass.txt ssh root@172.19.0.2
RUN mkdir /home/ubuntu/a2p08
COPY Benchmark.py /home/ubuntu/a2p08/
COPY Dudefile /home/ubuntu/a2p08/
COPY graphs.R /home/ubuntu/a2p08/
COPY run.sh /home/ubuntu/a2p08/
WORKDIR /home/ubuntu/a2p08/
RUN chmod 777 *
USER ubuntu
EXPOSE 10023
CMD ["/usr/sbin/sshd", "-D"]