Out-of-the-box Ubuntu image (14.04 LTS Trusty Tahr) set up to run an OpenSSH server.
Building the image
If you don't want to pull the
morganhjk/sshd image from the [automated build repository]
(https://registry.hub.docker.com/u/morganhjk/sshd/) on the [Docker Hub Registry]
(https://registry.hub.docker.com/), you can clone the [repository on GitHub]
(https://github.com/morganhjk/docker-sshd) and build the image
locally by executing the following command inside the docker-sshd folder:
docker build -t morganhjk/sshd .
Running the image
To run a container with the image, execute the following command:
docker run -d -P --name some_sshd -v /path/to/users:/sshusers morganhjk/sshd
-v /path/to/users:/sshusers argument is important.
should be a directory that contains files like this:
<username> with the name of a user that should be created with ssh
access. The contents of the file should be any public keys for the user.
If the user should have permission to use
sudo, place the file in a subdirectory
sudoers instead (e.g.
The first time that you run your container, a random password will be generated
for the user
root and any other users defined in
To get the password(s), check the logs of the container by running:
docker logs <CONTAINER_ID>
You will see something like the following for the root user:
======================================================================== Finished setting the following password for the user "root": U0iSGVUCr7W3 You should change the password above as soon as possible! Since root login via SSH is not permitted, use one of the sudoers. ========================================================================
And something like this for any other user created:
======================================================================================= Finished creating the user "someuser" with the following password: HQPf6hU4lXlz uid=1001(someuser) gid=1002(someuser) groups=1002(someuser),27(sudo),1001(sshusers) If the user is a part of the sshusers group, you can ssh into this container using the following command: ssh -i /path/to/ssh/key -p <port> someuser@<host> You should change the password above as soon as possible! =======================================================================================
In this case,
U0iSGVUCr7W3 is the password assigned to the user
HQPf6hU4lXlz is the password assigned to the user
Setting a specific password for the root user
If you want to use a preset password for root instead of a randomly generated one,
you can set the environment variable
ROOT_PASS to your specific password when
running the container:
docker run -d -P -e ROOT_PASS="mypass" --name some_sshd -v /path/to/users:/sshusers morganhjk/sshd
credit to http://www.tutum.co