Giter Site home page Giter Site logo

yetone / advanced-ssh-config Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moul/assh

0.0 2.0 0.0 1.05 MB

:computer: Extended ssh configuration (.ssh/config) with regex, aliases, gateways, includes, command execution, variable expansion...

Home Page: https://pypi.python.org/pypi/advanced-ssh-config/

License: MIT License

Makefile 2.86% Python 97.14%

advanced-ssh-config's Introduction

Advanced SSH config

Travis PyPI version PyPI downloads License Requires.io 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.

Usage

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

Commands:
  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

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

Commmand line features

Gateway chaining

ssh foo.com/bar.com

Connect to bar.com using ssh and create a proxy on bar.com to foo.com. Then connect to foo.com using the created proxy on bar.com.

ssh foo.com/bar.com/baz.com

Connect to foo.com using bar.com/baz.com which itself uses baz.com.

Configuration features

  • regex for hostnames: gw.school-.*.domain.net
  • aliases: gate -> gate.domain.tld
  • gateways: transparent ssh connections chaining
  • includes: split configuration into multiple files
  • 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

~/.ssh/config.advanced

# Simple example
[foo.com]
user = pacman
port = 2222

[bar]
hostname = 1.2.3.4
gateways = foo.com   # `ssh bar` will use `foo.com` as gateway

[^vm-[0-9]*\.joe\.com$]
gateways = bar       # `ssh vm-42.joe.com will use `bar` as gateway which
                     # itself will use `foo.com` as gateway

[default]
ProxyCommand = assh --port=%p connect %h

# Complete example
[foo]
user = pacman
port = 2222
hostname = foo.com

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

[^vm-[0-9]*\.joe\.com$]
IdentityFile = ~/.ssh/root-joe
gateways = direct joe.com joe.com/bar
# Will try to ssh without proxy, then fallback to joe.com proxy, then
# fallback to joe.com through bar
DynamicForward = 43217
LocalForward = 1723 localhost:1723
ForwardX11 = yes

[default]
Includes = ~/.ssh/config.advanced2 ~/.ssh/config.advanced3
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 = ~

Installation

Download the latest build

$ curl -L https://github.com/moul/advanced-ssh-config/releases/download/v1.0.1/assh-`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 https://github.com/moul/advanced-ssh-config
$ 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

Tests

$ make test

Docker

Build

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

Run

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

Contributors

--

© 2009-2015 Manfred Touron - MIT License.

advanced-ssh-config's People

Contributors

bitdeli-chef avatar dldinternet avatar moul avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.