├── setup.sh ├── sshd.conf ├── 71-apt-cacher-ng ├── start.sh ├── README.md └── Dockerfile /setup.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sshd.conf: -------------------------------------------------------------------------------- 1 | [program:sshd] 2 | user=root 3 | command=/usr/sbin/sshd -D 4 | autorestart=true 5 | stopsignal=INT 6 | -------------------------------------------------------------------------------- /71-apt-cacher-ng: -------------------------------------------------------------------------------- 1 | #Acquire::http { Proxy "http://192.168.0.104:3142"; }; 2 | #Acquire::http { Proxy "http://192.168.2.3:3142"; }; 3 | #Acquire::http { Proxy "http://192.168.1.13:3142"; }; 4 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Put any tasks you would like to have carried 4 | # out when the container is first created here 5 | 6 | # Set the root passwd - grep docker logs for it 7 | ROOT_PASSWORD=`pwgen -c -n -1 12` 8 | echo "root:$ROOT_PASSWORD" | chpasswd 9 | echo "root login password: $ROOT_PASSWORD" 10 | 11 | # Also echo out the pg password written to 12 | # /PGPASSWORD.txt when the image was made 13 | # by start-postgres.sh 14 | 15 | # Launch supervisor 16 | supervisord -n 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-ssh 2 | ========== 3 | 4 | A simple docker container that runs ssh 5 | 6 | To build the image do: 7 | 8 | ``` 9 | docker build -t kartoza/ssh git://github.com/timlinux/docker-ssh 10 | ``` 11 | 12 | To run a container do: 13 | 14 | ``` 15 | docker run --name "ssh" -p 2222:22 -d -t kartoza/ssh 16 | ``` 17 | 18 | To log into your container do: 19 | 20 | ``` 21 | ssh root@localhost -p 2222 22 | ``` 23 | 24 | Default password will appear in docker logs: 25 | 26 | ``` 27 | docker logs | grep 'root login password' 28 | ``` 29 | 30 | ----------- 31 | 32 | Tim Sutton (tim@linfiniti.com) 33 | May 2014 34 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #--------- Generic stuff all our Dockerfiles should start with so we get caching ------------ 2 | FROM ubuntu:14.04 3 | MAINTAINER Tim Sutton 4 | 5 | RUN export DEBIAN_FRONTEND=noninteractive 6 | ENV DEBIAN_FRONTEND noninteractive 7 | RUN dpkg-divert --local --rename --add /sbin/initctl 8 | #RUN ln -s /bin/true /sbin/initctl 9 | 10 | # Use local cached debs from host (saves your bandwidth!) 11 | # Change ip below to that of your apt-cacher-ng host 12 | # Or comment this line out if you do not wish to use caching 13 | ADD 71-apt-cacher-ng /etc/apt/apt.conf.d/71-apt-cacher-ng 14 | 15 | RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list 16 | RUN apt-get -y update 17 | # socat can be used to proxy an external port and make it look like it is local 18 | RUN apt-get -y install ca-certificates socat openssh-server supervisor rpl pwgen 19 | RUN mkdir /var/run/sshd 20 | ADD sshd.conf /etc/supervisor/conf.d/sshd.conf 21 | 22 | # Ubuntu 14.04 by default only allows non pwd based root login 23 | # We disable that but also create an .ssh dir so you can copy 24 | # up your key. NOTE: This is not a particularly robust setup 25 | # security wise and we recommend to NOT expose ssh as a public 26 | # service. 27 | RUN rpl "PermitRootLogin without-password" "PermitRootLogin yes" /etc/ssh/sshd_config 28 | RUN mkdir /root/.ssh 29 | RUN chmod o-rwx /root/.ssh 30 | 31 | #-------------Application Specific Stuff ---------------------------------------------------- 32 | # Open port 22 so linked containers can see it 33 | EXPOSE 22 34 | 35 | # Run any additional tasks here that are too tedious to put in 36 | # this dockerfile directly. 37 | ADD setup.sh /setup.sh 38 | RUN chmod 0755 /setup.sh 39 | RUN /setup.sh 40 | 41 | # Called on first run of docker - will run supervisor 42 | ADD start.sh /start.sh 43 | RUN chmod 0755 /start.sh 44 | 45 | CMD /start.sh 46 | 47 | --------------------------------------------------------------------------------