MasonM / avsh

Augmented Vagrant sSH - Faster alternative to "vagrant ssh", with extra features
MIT License
3 stars 0 forks source link

Avsh No Maintenance Intended Build Status Code Climate Coverage

avsh ("Augmented Vagrant sSH") is a standalone script that can be used in place of vagrant ssh. It provides greatly increased performance and several extra features.

This project is unmaintained since I no longer use Vagrant, but I'll accept PRs.

Caveats

avsh makes a number of assumptions and shortcuts in order to achieve its performance goals, so it might not work (or be appropriate) for your setup.

Installation

Download the latest release and put it in your PATH, or run the following to put it in /usr/local/bin/:

curl -sL https://github.com/MasonM/avsh/releases/download/0.1.0/avsh \
  | sudo tee /usr/local/bin/avsh > /dev/null \
    && sudo chmod ugo+rx /usr/local/bin/avsh

avsh uses the same logic as Vagrant to find your Vagrantfile. If you only use a single Vagrantfile, add export VAGRANT_CWD="/vagrantfile_dir/" to your .bashrc or .zshrc to ensure avsh and Vagrant can always find it.

Usage

Usage: avsh [options] [--] COMMAND    execute given command via SSH
   or: avsh [options]                 start a login shell

Options:
    -m, --machine MACHINE            Target Vagrant machine(s).
                                     Can be specified as a plain string for a single machine, a
                                     comma-separated list for multiple machines, or a regular
                                     expression in the form /search/ for one or more machines.
                                     If not given, will infer from the Vagrantfile.
    -r, --reconnect                  Closes SSH multiplex socket if present and re-initializes it
    -s, --ssh-options OPTS           Additional options to pass to SSH, e.g. "-a -6"
    -d, --debug                      Verbosely print debugging info to STDOUT
    -v, --version                    Display version
    -h, --help                       Display help
    -c, --command COMMAND            Command to execute (only for compatibility with Vagrant SSH)

Multi-Machine Environments

If the -m flag is not given for a multi-machine environment, avsh will try to infer the machine to connect to using the synced folders defined in your Vagrantfile. It does this by matching the current working directory against each machine in the order they are defined, using the first machine that has a matching synced folder (taking into account ancestor directories). If none are found to match, it will use the primary machine if one exists, else it falls back to the first defined machine.

When executing a command on multiple machines, automatic synced folder switching is disabled, since that can lead to hard-to-predict behavior. Additionally, a pseudo-TTY will not be allocated (i.e. SSH will not be passed the '-t' flag).