Skip to content

Commit 1318df1

Browse files
committed
initial version
1 parent e732e31 commit 1318df1

File tree

7 files changed

+136
-1
lines changed

7 files changed

+136
-1
lines changed

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,59 @@
11
tutum-debian
22
============
33

4-
Out-of-the-box Debian docker image with SSH access
4+
Simple Debian docker images with SSH access
5+
6+
7+
Usage
8+
-----
9+
10+
To create the image `tutum/debian` with one tag per Debian release,
11+
execute the following commands on the tutum-debian folder:
12+
13+
docker build -t tutum/debian:squeeze squeeze/
14+
docker build -t tutum/debian:wheezy wheezy/
15+
16+
To create different images for every Debian release, with just one `latest` tag each,
17+
execute the following commands on the tutum-debian folder:
18+
19+
docker build -t tutum/debian-squeeze squeeze/
20+
docker build -t tutum/debian-wheezy wheezy/
21+
22+
23+
Running tutum/debian
24+
--------------------
25+
26+
To run a container from the image you created earlier with the `wheezy` tag
27+
binding it to port 2222 in all interfaces, execute:
28+
29+
docker run -d -p 2222:22 tutum/debian:wheezy
30+
31+
The first time that you run your container, a random password will be generated
32+
for user `root`. To get the password, check the logs of the container by running:
33+
34+
docker logs <CONTAINER_ID>
35+
36+
You will see an output like the following:
37+
38+
========================================================================
39+
You can now connect to this Debian container via SSH using:
40+
41+
ssh -p <port> root@<host>
42+
and enter the root password 'U0iSGVUCr7W3' when prompted
43+
44+
Please remember to change the above password as soon as possible!
45+
========================================================================
46+
47+
In this case, `U0iSGVUCr7W3` is the password allocated to the `root` user.
48+
49+
Done!
50+
51+
52+
Setting a specific password for the root account
53+
------------------------------------------------
54+
55+
If you want to use a preset password instead of a random generated one, you can
56+
set the environment variable `ROOT_PASS` to your specific password when running the container:
57+
58+
docker run -d -p 2222:22 -e ROOT_PASS="mypass" tutum/debian:wheezy
59+

squeeze/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM debian:squeeze
2+
MAINTAINER Fernando Mayo <fernando@tutum.co>
3+
4+
# Install packages
5+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server pwgen
6+
RUN mkdir -p /var/run/sshd && sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
7+
ADD set_root_pw.sh /set_root_pw.sh
8+
ADD run.sh /run.sh
9+
RUN chmod +x /*.sh
10+
11+
EXPOSE 22
12+
CMD ["/run.sh"]

squeeze/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
if [ ! -f /.root_pw_set ]; then
3+
/set_root_pw.sh
4+
fi
5+
exec /usr/sbin/sshd -D

squeeze/set_root_pw.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [ -f /.root_pw_set ]; then
4+
echo "Root password already set!"
5+
exit 0
6+
fi
7+
8+
PASS=${ROOT_PASS:-$(pwgen -s 12 1)}
9+
_word=$( [ ${ROOT_PASS} ] && echo "preset" || echo "random" )
10+
echo "=> Setting a ${_word} password to the root user"
11+
echo "root:$PASS" | chpasswd
12+
13+
echo "=> Done!"
14+
touch /.root_pw_set
15+
16+
echo "========================================================================"
17+
echo "You can now connect to this Debian container via SSH using:"
18+
echo ""
19+
echo " ssh -p <port> root@<host>"
20+
echo "and enter the root password '$PASS' when prompted"
21+
echo ""
22+
echo "Please remember to change the above password as soon as possible!"
23+
echo "========================================================================"

wheezy/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM debian:wheezy
2+
MAINTAINER Fernando Mayo <fernando@tutum.co>
3+
4+
# Install packages
5+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server pwgen
6+
RUN mkdir -p /var/run/sshd && sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
7+
ADD set_root_pw.sh /set_root_pw.sh
8+
ADD run.sh /run.sh
9+
RUN chmod +x /*.sh
10+
11+
EXPOSE 22
12+
CMD ["/run.sh"]

wheezy/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
if [ ! -f /.root_pw_set ]; then
3+
/set_root_pw.sh
4+
fi
5+
exec /usr/sbin/sshd -D

wheezy/set_root_pw.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [ -f /.root_pw_set ]; then
4+
echo "Root password already set!"
5+
exit 0
6+
fi
7+
8+
PASS=${ROOT_PASS:-$(pwgen -s 12 1)}
9+
_word=$( [ ${ROOT_PASS} ] && echo "preset" || echo "random" )
10+
echo "=> Setting a ${_word} password to the root user"
11+
echo "root:$PASS" | chpasswd
12+
13+
echo "=> Done!"
14+
touch /.root_pw_set
15+
16+
echo "========================================================================"
17+
echo "You can now connect to this Debian container via SSH using:"
18+
echo ""
19+
echo " ssh -p <port> root@<host>"
20+
echo "and enter the root password '$PASS' when prompted"
21+
echo ""
22+
echo "Please remember to change the above password as soon as possible!"
23+
echo "========================================================================"

0 commit comments

Comments
 (0)