master
Raw Download raw file
 1FROM ubuntu:latest
 2
 3# build with:  sudo docker build --tag ssh-ks .
 4# run with:    sudo docker run -d ssh-ks
 5
 6ARG user=ubuntu
 7ARG pass=susquehanna
 8ARG gh_user=bryfry
 9
10RUN apt-get update                                                                                            
11RUN apt-get install -y jq curl sudo vim openssh-server man less                                               && \ 
12    mkdir /var/run/sshd                                                                                       && \
13    echo "AllowAgentForwarding yes" >> /etc/ssh/sshd_config                                                   
14
15# create user, set password, make passwordless sudoer, add authorized key
16RUN useradd --create-home --shell /bin/bash ${user}                                                           && \ 
17    install --directory --owner=${user} --group=${user} /home/${user}/.ssh                                    && \ 
18    echo "${user}:${pass}" | chpasswd                                                                         && \ 
19    echo "export LC_ALL=C" >> /home/${user}/.bashrc                                                           && \
20    echo "${user}	ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers                                              && \
21    curl -s https://api.github.com/users/${gh_user}/keys | jq -r '.[] | .key' > /home/${user}/.ssh/authorized_keys
22
23EXPOSE 22
24CMD ["/usr/sbin/sshd","-D"]
25