Skip to content
Implementing contexts for ssh in kubectl way
Branch: master
Clone or download
Latest commit ef0ed15 Jun 27, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Update README.md Jun 27, 2019
ssh-context autoreplace symlink to ~/.ssh/config on switch Nov 19, 2018

README.md

ssh-context Donate

Bash wrapper around ssh which provides you ability to use contexts (as in kubectl) for SSH.

Better to describe it with example.

  1. You are developer involved in multiple projects. Each project has own dev/staging/production servers, git services, ssh keys, etc.
  2. You don't want to manually enter ssh key location each time (or mix your ssh config file).
  3. You want to share ssh config of one of the projects.
  4. It's not usable to do that with standard ssh toolchain

And here is ssh-context.

  1. Project = context
  2. Context = separate ssh config, keys, etc.
  3. Use full power of isolated ssh config

Installation

Just place ssh-context bash script in any location from your $PATH, chmod +x against it and run ssh-context bootstrap to init file structure

Optional: Set ssh-context as alias for ssh

Bash: Add this alias to .bashrc or .bash_profile (for OSX):

ZSH: Add this alias to .zshrc

Fish: Add this alias to config.fish

alias ssh="ssh-context wrapper"

Usage

Install ssh-context

ssh-context bootstrap

Create new context

ssh-context init myproject

Switch context

ssh-context switch context_name

Connect with current context

ssh-context wrapper <ssh args>
# example:
ssh-context wrapper -vv user@server

Connect with another context

ssh-context wrapper <context> <ssh args>
# example:
ssh-context wrapper anotherproject server
You can’t perform that action at this time.