-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile
47 lines (35 loc) · 1.37 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM debian:9
MAINTAINER Chu-Siang Lai <chusiang@drx.tw>
# Update the index of available packages.
RUN apt-get update
# Install the requires package.
RUN apt-get install -y openssh-server python sudo openssl curl wget bash-completion openssl \
&& \
apt-get clean
# Setting the sshd.
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
RUN sed -i 's/PermitRootLogin without-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
# Create a new user.
#
# - username: docker
# - password: docker
RUN useradd --create-home --shell /bin/bash \
--password $(openssl passwd -1 docker) docker
# Add sudo permission.
RUN echo 'docker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Setting ssh public key.
RUN wget https://raw.githubusercontent.com/chusiang/ansible-jupyter.dockerfile/master/files/ssh/id_rsa.pub \
-O /tmp/authorized_keys && \
mkdir /home/docker/.ssh && \
mv /tmp/authorized_keys /home/docker/.ssh/ && \
chown -R docker:docker /home/docker/.ssh/ && \
chmod 644 /home/docker/.ssh/authorized_keys && \
chmod 700 /home/docker/.ssh
EXPOSE 22
# Run ssh server daemon.
CMD ["/usr/sbin/sshd", "-D"]