:title: Running an SSH service
:description: A screencast of installing and running an sshd service
:keywords: docker, example, package installation, networking

.. _running_ssh_service:

SSH Daemon Service
==================

.. include:: example_header.inc


**Video:**

I've create a little screencast to show how to create a sshd service and connect to it. It is something like 11
minutes and not entirely smooth, but gives you a good idea.

.. raw:: html

    <div style="margin-top:10px;">
      <iframe width="800" height="400" src="http://ascii.io/a/2637/raw" frameborder="0"></iframe>
    </div>
	
You can also get this sshd container by using
::

    docker pull dhrp/sshd


The password is 'screencast'

**Video's Transcription:**

.. code-block:: bash

	 # Hello! We are going to try and install openssh on a container and run it as a servic 
	 # let's pull base to get a base ubuntu image. 
	 $ docker pull base
	 # I had it so it was quick
	 # now let's connect using -i for interactive and with -t for terminal 
	 # we execute /bin/bash to get a prompt.
	 $ docker run -i -t base /bin/bash
	 # now let's commit it 
	 # which container was it?
	 $ docker ps -a |more
	 $ docker commit a30a3a2f2b130749995f5902f079dc6ad31ea0621fac595128ec59c6da07feea dhrp/sshd 
	 # I gave the name dhrp/sshd for the container
	 # now we can run it again 
	 $ docker run -d dhrp/sshd /usr/sbin/sshd -D # D for daemon mode 
	 # is it running?
	 $ docker ps
	 # yes!
	 # let's stop it 
	 $ docker stop 0ebf7cec294755399d063f4b1627980d4cbff7d999f0bc82b59c300f8536a562
	 $ docker ps
	 # and reconnect, but now open a port to it
	 $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 
	 $ docker port b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 22
	 # it has now given us a port to connect to
	 # we have to connect using a public ip of our host
	 $ hostname
	 $ ifconfig
	 $ ssh root@192.168.33.10 -p 49153
	 # Ah! forgot to set root passwd
	 $ docker commit b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 dhrp/sshd 
	 $ docker ps -a
	 $ docker run -i -t dhrp/sshd /bin/bash
	 $ passwd
	 $ exit
	 $ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd
	 $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D
	 $ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22
	 $ ifconfig
	 $ ssh root@192.168.33.10 -p 49154
	 # Thanks for watching, Thatcher thatcher@dotcloud.com