Skip to main content

Add some magic to SSH and .ssh/config

Project description

PyPI version Build Status authors library users Total views Views in the last 24 hours PyPi downloads Bitdeli Badge Gitter chat

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.

Note: Each time the script is called, it recreate a fresh new ``.ssh/config``, so be careful, backup your old .ssh/config file !

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
  • gateways - transparent ssh connections chaining
  • includes files
  • real local command - executes a command on the local shell when connecting
  • intelligent proxycommand with fallbacks
  • inherits configuration
  • variable expansion

Config example


# Simple example
user = pacman
port = 2222

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

ProxyCommand = advanced-ssh-config --hostname=%h --port=%p -u

# 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
Port = 22
User = root
IdentityFile = ~/.ssh/id_rsa
ProxyCommand = advanced-ssh-config --hostname=%h --port=%p -u
Gateways = direct
PubkeyAuthentication = yes
VisualHostKey = yes
ControlMaster = auto
ControlPath = ~/.ssh/controlmaster/%h-%p-%r.sock
EscapeChar = ~


From Pypi

# pip install advanced-ssh-config

Or by cloning

# git clone
# cd advanced-ssh-config
# python install

Backup your old ~/.ssh/config file

# cp ~/.ssh/config ~/.ssh/config.backup

Generate the new config file

# advanced-ssh-config -u

Or add this line manually in your ~/.ssh/config file

ProxyCommand = advanced-ssh-config --hostname=%h --port=%p -u


Install test dependencies and run tests

# python test


# pep8 advanced_ssh_config | grep -v /tests/



# 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.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for advanced-ssh-config, version 0.18.0
Filename, size File type Python version Upload date Hashes
Filename, size advanced-ssh-config-0.18.0.macosx-10.10-intel.tar.gz (37.9 kB) File type Dumb Binary Python version any Upload date Hashes View hashes
Filename, size advanced_ssh_config-0.18.0-py26-none-any.whl (24.6 kB) File type Wheel Python version 2.6 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page