Public | Automated Build

Last pushed: 2 years ago
Short Description
An SSH image which only allows key login.
Full Description


An SSH image which only allows key login.


  1. The user can only login with it's ssh key file. The password login is disabled by default.

  2. Use the outside VOLUME to control the image start command, don't need to rebuild the image any more.

(Optional) Build image from git

If you want to buid the image yourself:

  1. You need to install docker first. If you don't know how to do this, refer to :

  2. Clone this repo:

     git clone path_to_docker-ssh
  3. Build the image:

     docker build -t myssh path_to_docker-ssh

Get image from docker hub (Suggested)

  1. Install Docker.

  2. Open your docker terminal

  3. Pull the image from docker:

     docker pull karasshi/ssh-key

How to run container

  1. You need to generate you own ssh key pairs. If you don't know what they are and what to do, refer to : SSH Keys

  2. When you got your own "" file, copy that file to a folder which will be passed to the container as a volume. It must be in a folder called "sshkey" and must be named "authorized_keys". For example:

     cp ~/.ssh/ ~/volume/sshkey/authorized_keys
  3. Make a file in "volume" folder to control the start process of the container:

    1. Make a new file called

    2. Edit the file as follow:

       echo 'Begin'
       # You can add any command you need here:
       # Copy the user-defined public keys to ssh
       /bin/cp /vol/sshkey/authorized_keys /home/admin/.ssh/authorized_keys
       # Start ssh server
       /usr/sbin/sshd -D
       echo ' ended.'
    3. Save the file in ~/volume/start folder.

  4. Run the container with commands below:

     docker run -d -P --name testssh -v ~/volume:/vol karasshi/ssh-key
  5. Find the port:

     docker port testssh 22

How to login

  1. Find you docker host's IP, for example:

  2. Login to the container:

     ssh admin@ -p 32779

    NOTE1: You can only use the username "admin".

    NOTE2: You can not use the password to login, you can only use the machine which contains you own private key in ~/.ssh

Docker Pull Command
Source Repository