Sign inSign up

cyd01/sshd-alpine

By cyd01

•Updated 3 months ago

Alpine linux distribution with sshd daemon started

Image
0

1.4K

cyd01/sshd-alpine repository overview

Two users are created:

  • root/root01
  • user/user01

⁠Dockerfile

FROM alpine
MAINTAINER Cyd "[email protected]"

USER root

RUN apk add --no-cache openssh \
  && sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config \
  && echo "root:root01" | chpasswd

RUN apk add --no-cache \
  curl \
  mlocate \
  openssl \
  perl \
  sudo \
  tmux \
  unzip
  
RUN echo "Welcome to Alpine!" > /etc/motd

RUN adduser -D -s /bin/ash user && \
  passwd -u user && \
  chown -R user:user /home/user

RUN echo "user:user01" | chpasswd

COPY profile /home/user/.profile
COPY openstack.ppk /home/user/.ssh/id_rsa.ppk
COPY openstack.id_rsa /home/user/.ssh/id_rsa
COPY openstack.pub /home/user/.ssh/id_rsa.pub
COPY authorized_keys /home/user/.ssh/authorized_keys
COPY Dockerfile /etc/Dockerfile

RUN \
  chown -R user:user /home/user && chmod 400 /home/user/.ssh/* && chmod 700 /home/user/.ssh

COPY rootfs /
RUN chmod +x /entrypoint.sh

EXPOSE 22

ENTRYPOINT ["/entrypoint.sh"]

# docker build . -t cyd01/sshd-alpine
# docker system prune -f
# docker rm -f sshd ; docker run --rm -d -p 2022:22 --name=sshd cyd01/sshd-alpine
# docker push cyd01/sshd-alpine

⁠entrypoint.sh

#!/bin/ash

# generate host keys if not present
ssh-keygen -A

# do not detach (-D), log to stderr (-e), passthrough other arguments
exec /usr/sbin/sshd -D -e "$@"

Tag summary

Content type

Image

Digest

sha256:10b947e51…

Size

20.2 MB

Last updated

3 months ago

docker pull cyd01/sshd-alpine