Public | Automated Build

Last pushed: 3 years ago
Short Description
Simple Docker image to run an OpenSSH server.
Full Description


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]
( on the [Docker Hub Registry]
(, you can clone the [repository on GitHub]
( and build the image morganhjk/sshd
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

The -v /path/to/users:/sshusers argument is important. /path/to/users
should be a directory that contains files like this: <username>.user.
Replace <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
called sudoers instead (e.g. /path/to/users/sudoers/<username>.user).

The first time that you run your container, a random password will be generated
for the user root and any other users defined in /path/to/users.
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":

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:

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 root, and
HQPf6hU4lXlz is the password assigned to the user someuser.


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

Docker Pull Command
Source Repository