-
Notifications
You must be signed in to change notification settings - Fork 1
/
ubuntu_ssh
45 lines (38 loc) · 1.71 KB
/
ubuntu_ssh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#########################################################################
# -- Author: Amos Folarin #
# -- Organisation: KCL/SLaM #
# -- Email: amosfolarin@gmail.com #
#########################################################################
#------------------------------------------------------------------------
#
#------------------------------------------------------------------------
# sshd
#
# VERSION 0.0.1
FROM ubuntu
MAINTAINER Amos Folarin "amosfolarin@gmail.com"
# make sure the package repository is up to date (main is already listed by default)
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
# verify repository content (useful if you are doing more than just a oneline sources.list)
RUN cat /etc/apt/sources.list
# update from the repos
RUN apt-get update
# install the ssh server (openssh in this case)
RUN apt-get install -y openssh-server
# setup the run folder for the service
RUN mkdir /var/run/sshd
# add a passowrd for root account
RUN echo 'root:theprestige' |chpasswd
# expose port 22 which sshd listens on
EXPOSE 22
CMD /usr/sbin/sshd -D
# Example Usage:
# 1. build the docker image with this docker file "ubuntu_ssh", (with repo:tag)
# sudo docker build --tag="afolarin/ubuntu_ssh:sshbox" - < ubuntu_ssh
# 2. run the container (with a name)
# docker run -d --name box1 afolarin/ubuntu_ssh:v1.1
# 3. inspect the interface ip of the container
# ip_box1=$(sudo docker inspect box1 | grep '"IPAddress":' | awk -F'"' '{print $4}')
# 4. ssh from the host onto the container
# ssh root@${ip_box1}
# password "theprestige"