Skip to content

Instantly share code, notes, and snippets.

@pi0
Created June 19, 2022 19:16
Show Gist options
  • Save pi0/a7f734a69d34cc3cb2d67ec862cfa3ac to your computer and use it in GitHub Desktop.
Save pi0/a7f734a69d34cc3cb2d67ec862cfa3ac to your computer and use it in GitHub Desktop.
Mikrotik linux docker files
FROM alpine
RUN apk update && \
apk upgrade && \
apk add openssh-server htop curl wget iperf3 vim && \
rm -rf /var/cache/apk
RUN cat /etc/ssh/sshd_config | grep -v "^#" | grep -v "^$" > /sshd_config && \
echo "PermitRootLogin yes" >> /sshd_config && \
echo "PrintMotd no" >> /sshd_config && \
rm -rf /etc/ssh /root && \
ln -s /data/ssh /etc/ssh && \
ln -s /data/root /root && \
ln -s /data/log /var/log
ENTRYPOINT /entry.sh
VOLUME /data
COPY ./entry.sh /
FROM alpine
RUN apk update && \
apk upgrade && \
apk add openssh-server && \
rm -rf /var/cache/apk
RUN cat /etc/ssh/sshd_config | grep -v "^#" | grep -v "^$" > /sshd_config && \
echo "PermitRootLogin yes" >> /sshd_config && \
echo "PrintMotd no" >> /sshd_config && \
rm -rf /etc/ssh /root && \
ln -s /data/ssh /etc/ssh && \
ln -s /data/root /root && \
ln -s /data/log /var/log
ENTRYPOINT /entry.sh
VOLUME /data
COPY ./entry.sh /
FROM debian:11
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install openssh-server zsh tmux aria2 htop pv speedtest-cli vim curl wget netcat iperf3 iputils-ping iputils-tracepath iputils-arping iproute2 -y && \
rm -rf /var/lib/apt
RUN cat /etc/ssh/sshd_config | grep -v "^#" | grep -v "^$" > /sshd_config && \
echo "PermitRootLogin yes" >> /sshd_config && \
echo "" > /etc/motd && \
rm -rf /etc/ssh /root && \
mkdir -p /run/sshd && \
ln -s /data/ssh /etc/ssh && \
ln -s /data/root /root && \
ln -s /data/log /var/log
ENTRYPOINT /entry.sh
VOLUME /data
COPY ./entry.sh /
#!/bin/sh
set -e
PASSWD=${PASSWD:-letmein}
echo "Initializing env..."
mkdir -p /data/ssh /data/root /data/log
touch /var/log/wtmp
chmod 0664 /var/log/wtmp
chown root:utmp /var/log/wtmp
echo "Generating server keys..."
ssh-keygen -A
echo "Setting password for root user..."
echo "Password: $PASSWD"
echo "root:${PASSWD}" | chpasswd
echo "Starting ssh server..."
/usr/sbin/sshd -eD -f /sshd_config%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment