-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-ssh
53 lines (40 loc) · 1.43 KB
/
Dockerfile-ssh
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
47
48
49
50
51
52
53
FROM ubuntu:20.04
ENV TZ=America/Toronto
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
## Install additional packes
RUN apt-get update && \
apt-get -y install curl openssh-server dnsutils sudo git mc python3-pip && \
apt-get clean
## Install go or other dependencies that you need for development
ARG goarchive=go1.15.3.linux-amd64.tar.gz
RUN curl -O https://dl.google.com/go/$goarchive && tar -C /usr/local -xzf $goarchive && rm $goarchive
RUN echo export PATH=$PATH:/usr/local/go/bin >> /etc/profile
RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
RUN apt -y install nodejs
## Create development user
ARG user=gleb
RUN useradd -ms /bin/bash $user
RUN mkdir /home/$user/.ssh
RUN mkdir /home/$user/bin
ADD sshd_starter.py /home/$user/bin/sshd_starter.py
ADD --chown=$user:$user authorized_keys home/$user/.ssh/authorized_keys
RUN echo "gleb ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/gleb
## Configure openssh server
RUN echo "\n\
PasswordAuthentication no \n\
PermitRootLogin no \n\
MaxAuthTries 3 \n\
LoginGraceTime 10 \n\
PermitEmptyPasswords no \n\
ChallengeResponseAuthentication no \n\
KerberosAuthentication no \n\
GSSAPIAuthentication no \n\
X11Forwarding no \n\
HostKey /etc/ssh/ssh_host_rsa_key \n\
LogLevel INFO \n\
" >> /etc/ssh/sshd_config
RUN mkdir /run/sshd
RUN cd /etc/ssh && ssh-keygen -A
USER root
CMD /home/gleb/bin/sshd_starter.py && sleep infinity
EXPOSE 22 3000