Skip to content


Subversion checkout URL

You can clone with
Download ZIP
:computer: ASSH: Extended ssh configuration (.ssh/config) with regex, aliases, gateways, includes, command execution, variable expansion...
Python Makefile


latest commit 6901ad1d59
@moul authored

Advanced SSH config

Travis PyPI version PyPI downloads License Gitter

ASSH logo - Advanced SSH Config logo

Enhances ssh_config file capabilities

NOTE: This program is called by ProxyCommand from lib-ssh.

It works transparently with :

The .ssh/config file is automatically generated, you need to update .ssh/config.advanced file instead; With new features and a better regex engine for the hostnames.


$ assh --help
Usage: assh [OPTIONS] COMMAND [arg...]

  build                 Build .ssh/config based on .ssh/config.advanced
  connect <host>        Open a connection to <host>
  info <host>           Print connection informations
  init                  Build a .ssh/config.advanced file based on .ssh/config
  generate-etc-hosts    Print a /etc/hosts file of .ssh/config.advanced
  stats                 Print statistics

  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  SSH port
                        ssh_config file
  -f, --force
  -v, --verbose
  -l LOG_LEVEL, --log_level=LOG_LEVEL

Commmand line features

Gateway chaining


Connect to using ssh and create a proxy on to Then connect to using the created proxy on


Connect to using which itself uses

Configuration features

  • regex for hostnames:*
  • aliases: gate -> gate.domain.tld
  • gateways: transparent ssh connections chaining
  • includes: split configuration into multiple files, support globbing
  • local command execution: finally a way to execute a command locally on connection
  • inheritance: inherits = gate.domain.tld
  • variable expansion: User = $USER (take $USER from environment)
  • smart proxycommand: connect using netcat, socat or custom handler

Config example


# Simple example
user = pacman
port = 2222

hostname =
gateways =   # `ssh bar` will use `` as gateway

gateways = bar       # `ssh will use `bar` as gateway which
                     # itself will use `` as gateway

ProxyCommand = assh --port=%p connect %h

# Complete example
user = pacman
port = 2222
hostname =

hostname =
gateways = foo
# By running `ssh bar`, you will ssh to `bar` through a `ssh foo`

IdentityFile = ~/.ssh/root-joe

gateways = direct
# Will try to ssh without proxy, then fallback to proxy, then
# fallback to through bar

DynamicForward = 43217
LocalForward = 1723 localhost:1723
ForwardX11 = yes

Includes = ~/.ssh/config.advanced2 ~/.ssh/config.advanced3 ~/.ssh/configs/*/host.config
# The `Includes` directive must be in the `[default]` section

Port = 22
User = root
IdentityFile = ~/.ssh/id_rsa
ProxyCommand = assh connect %h --port=%p
Gateways = direct
PubkeyAuthentication = yes
VisualHostKey = yes
ControlMaster = auto
ControlPath = ~/.ssh/controlmaster/%h-%p-%r.sock
EscapeChar = ~


Download the latest build

$ curl -L`uname -s`-`uname -m` > /usr/local/bin/assh
$ chmod +x /usr/local/bin/assh

Using Pypi

$ pip install advanced-ssh-config

Or by cloning

$ git clone
$ cd advanced-ssh-config
$ make install

First run

Automatically generate a new .ssh/config.advanced based on your current .ssh/config file:

$ assh init > ~/.ssh/config.advanced
$ assh build -f


$ make test



$ docker build -t moul/advanced-ssh-config .


$ docker run -rm -i -t moul/advanced-ssh-config
$ docker run -rm -i -t -v $(pwd)/:/advanced_ssh_config moul/advanced-ssh-config
$ docker run -rm -i -t -v moul/advanced-ssh-config python test


© 2009-2015 Manfred Touron - MIT License.

Something went wrong with that request. Please try again.