Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Enable Dynamic SSH Autocompletion

byt3bl33d3r edited this page Oct 20, 2018 · 9 revisions

Enable Dynamic SSH Autocompletion

Commit 59f7377 (among many other things) added support for dynamic SSH autocompletion: for every piece of created infrastructure Red-Baron now dynamically creates an associated ssh-config file.

This allows for our created infrastructure to show up when we tab-complete the ssh command which in turn makes accessing all the created instances incredibly easy and straight forward.

In theory, the only requirement to make this work is that you need to have OpenSSH version 7.3p1 and up which introduced the Include keyword (see here for more information).

In practice, Bash nor Zsh support autocompleting config file entries specified using the Include keyword out of the box.

I only figured out how to make this work using Zsh with the oh-my-zsh framework which is the setup I use.

Bash

If someone gets this working with Bash, fell free to add a guide here.

Zsh with Oh-My-Zsh

  • Put the following at the very top of your ~/.ssh/config file, make sure to use the absolute path to the Red-Baron folder:
Include <Path to Red-Baron folder>/data/ssh_configs/*
  • Copy the custom ssh completion file (which was stolen from here) under autocompletions/zsh to your oh-my-zsh folder:
cp ~/Red-Baron/autocompletions/zsh/_ssh ~/.oh-my-zsh/completions
  • Restart your terminal

  • All created infrastructure will now show up when you tab complete the ssh command! e.g. ssh http<TAB>