April 3, 2016 · automation docker hacks linux ssh workflow

Python SSH gateway in Docker container

I've created a small, portable and lightweight Docker container acting as an SSH gateway to your remote hosts.
It may be useful especially if you have a lot of remote machines you manage and use more than one local machine to connect to them.

The Docker image is based on Alpine Linux 3.3 and weighs only 45 MB.


  • Pull the image from Docker Registry:
docker pull bbania/ssh-gateway
  • Create an SSH key to be used inside Docker container:
ssh-keygen -t rsa -b 4096 -C <your_comment>
  • Add the ssh key to your remote hosts' ~/.ssh/authorized_keys file.

  • Create ssh_config file with list of your hosts. Example config on github repo.

  • Edit menulist.py

  • menu_data to set menu entries for your hosts

  • Format:

    • title - provides menu title
    • subtitle - additional title for menu
    • type (takes either MENU or COMMAND values):
    • MENU - creates a menu entity (requires subtitle to be set as well as options for submenu)
    • COMMAND - executes a shell command

Example menu_data in menulist.py.

Running the container

Pass menulist.py, ssh key and ssh_config to the container as volumes:

docker run --rm -it \ 
       -v /path/to/ssh_config:/etc/ssh/ssh_config \
       -v /path/to/ssh-key:/root/.ssh/id_rsa \
       -v /path/to/menulist.py:/menulist.py bbania/ssh-gateway

And that's it!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket