Public Repository

Last pushed: 9 months ago
Short Description
sshd-alpine pubkey-only sshd server for minimalist.
Full Description

Usage

Build

ssh-keygen -t ed25519 # create id_ed25519/id_ed25519.pub at current dir
docker build -t legalnetwork/sshd .

Run

docker run -d --rm -p 2222:22 legalnetwork/sshd

Connecting

ssh -i id_ed25519 -p 2222 user@host.ip

Docker file

FROM alpine
MAINTAINER Tomo Iida <iida@legalnetwork.jp>

RUN apk add --update --no-cache openssh && \
  rm -rf /tmp/* /var/cache/apk/* && \
  adduser -D user && \
  passwd -u user && \
  # SSHD CONFIG
  { \
    echo "PermitRootLogin prohibit-password"; \
    echo "PasswordAuthentication no"; \
  } >> /etc/ssh/sshd_config && \
  # GENERATE KEYS
  { \
    echo "$PASS=PASS$RANDOM"; \
    echo "PASSWORD for user is $PASS"; \
    echo "echo -e $PASS'\n'$PASS | passwd user"; \
    echo "ssh-keygen -A"; \
    echo 'exec "$@"'; \
  } > /usr/sbin/key_gen.sh
COPY id_ed25519.pub /home/user/.ssh/authorized_keys
RUN chown -R user.user /home/user && \
  chmod 700 /home/user/.ssh && \
  chmod 600 /home/user/.ssh/authorized_keys

ENTRYPOINT ["ash", "/usr/sbin/key_gen.sh"]
CMD ["/usr/sbin/sshd", "-D", "-E", "/var/log/auth.log"]
Docker Pull Command
Owner
legalnetwork