diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4c7b9f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:edge +MAINTAINER Daniel Guerra + +RUN apk add --update openssh + +RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa + +RUN sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config && sed -i "s/UsePAM.*/UsePAM no/g" /etc/ssh/sshd_config && sed -i "s/PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && sed -i "s/#AuthorizedKeysFile/AuthorizedKeysFile/g" /etc/ssh/sshd_config + +CMD ["/usr/sbin/sshd","-D"] diff --git a/Readme.rst b/Readme.rst new file mode 100644 index 0000000..bc88c4e --- /dev/null +++ b/Readme.rst @@ -0,0 +1,36 @@ +Alipne ssh server + +### Dependencies + +* [![2.0.0](https://badge.imagelayers.io/alpine.svg)](https://imagelayers.io/?images=alpine:edge 'edge') alpine:edge + +### Image size + +[![Latest](https://badge.imagelayers.io/danielguerra/apline-sshd.svg)](https://imagelayers.io/?images=danielguerra/alpine-sshd:latest 'latest') danielguerra/alpine-sshd + +### Instructions + +create a ssh volume +```bash +$ docker create -v /root/.ssh --name ssh-container danielguerra/ssh-container /bin/true +``` +create your own keys +```bash +$ docker run --volumes-from ssh-container alpine:edge ssh-keygen -q +``` +add your pub key to authorized_keys file +```bash +$ docker run --volumes-from ssh-container alpine:edge cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys +``` +create a copy in your directory (pwd) +```bash +$ docker run --volumes-from ssh-container -v $(pwd):/backup alpine:edge cp -R /root/.ssh/* /backup +``` +start ssh server +```bash +docker run -d -p 9022:22 --volumes-from ssh-container --name=alpine-sshd --hostname=alpine-sshd danielguerra/alpine-sshd + ``` + ssh to your server + ```bash + ssh -i id_rsa -p 9022 root@ + ```