-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
55 lines (48 loc) · 1.71 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
47
48
49
50
51
52
53
54
55
FROM debian:stretch
MAINTAINER Pierre GINDRAUD <pgindraud@gmail.com>
ENV LDAP_URI=ldap://ldap.host.net/ \
LDAP_BASE=dc=example,dc=com \
LDAP_TLS_STARTTLS=false \
LDAP_HOMEDIR=%u \
LDAP_ATTR_SSHPUBLICKEY=sshPublicKey \
SFTP_CHROOT=/data
# LDAP_BASE_USER=cn=users,dc=example,dc=com
# LDAP_BASE_GROUP=cn=groups,dc=example,dc=com
# LDAP_BIND_USER=cn=sssd,dc=example,dc=net
# LDAP_BIND_PWD=xxxxxxxx
# LDAP_TLS_CACERT=/etc/ssl/ca.crt
# LDAP_TLS_CERT=/etc/ssl/cert.crt
# LDAP_TLS_KEY=/etc/ssl/cert.key
# Install dependencies
RUN apt-get update && apt-get install -y \
libnss-sss \
libpam-sss \
openssh-server \
openssh-sftp-server \
sssd-ldap \
supervisor && \
# Clean dependencies
apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* && \
# Remove default debian keys
rm -f /etc/ssh/ssh_host_*key* && \
mkdir /var/run/sshd && chmod 0755 /var/run/sshd && \
# Prepare data dir
mkdir -p /data && \
# Configure sshd
sed -i 's|^AuthorizedKeysFile|#AuthorizedKeysFile|' /etc/ssh/sshd_config && \
echo 'AuthorizedKeysFile /dev/null' >> /etc/ssh/sshd_config && \
echo 'AuthorizedKeysCommandUser nobody' >> /etc/ssh/sshd_config && \
echo 'AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys' >> /etc/ssh/sshd_config && \
sed -i 's|sftp-server$|sftp-server -e -u 002|' /etc/ssh/sshd_config && \
echo 'ForceCommand internal-sftp' >> /etc/ssh/sshd_config && \
echo 'ChrootDirectory SFTP_CHROOT' >> /etc/ssh/sshd_config
# copy local files
COPY root/ /
RUN chown root:root /data && \
chmod 755 /data && \
chmod 600 /etc/sssd/sssd.conf && \
chmod +x /start.sh
EXPOSE 22
VOLUME ["/data"]
WORKDIR /data
CMD ["/start.sh"]