https://github.com/rakshazi/ssh-context
Implementing contexts for ssh in kubectl way
https://github.com/rakshazi/ssh-context
content-management ssh ssh-client ssh-config ssh-context ssh-key structure
Last synced: 3 months ago
JSON representation
Implementing contexts for ssh in kubectl way
- Host: GitHub
- URL: https://github.com/rakshazi/ssh-context
- Owner: rakshazi
- Created: 2018-06-29T10:45:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-08T11:01:01.000Z (over 4 years ago)
- Last Synced: 2025-01-21T07:11:34.229Z (4 months ago)
- Topics: content-management, ssh, ssh-client, ssh-config, ssh-context, ssh-key, structure
- Language: Shell
- Size: 5.86 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ssh-context [](https://liberapay.com/rakshazi/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 toolchainAnd here is ssh-context.
1. Project = context
2. Context = separate ssh config, keys, git repos, 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`
```bash
alias ssh="ssh-context wrapper"
```### Set context per git repo
If you have multiple git repos, like `project1`, `project2`, `projectN`, etc. you may want to use them with different contexts.
In that case, run `ssh-context switch CONTEXT_YOU_WANT_TO_USE_FOR_THAT_GIT_REPO` and context name will be saved to `git config ssh.context` var
in your local repo (remote not affected).## Usage
**Install ssh-context**
```bash
ssh-context bootstrap
```**Create new context**
```bash
ssh-context init myproject
```**Switch context**
> **NOTE**: if you run `switch` inside the folder with git repo,
> context name will be saved to `git config ssh.context`,
> so next time when you will ssh from that folder, context from `git config ssh.context`
> will be used automaticly, if you don't set context name explicitly.```bash
ssh-context switch context_name
```**Connect with current context**
```bash
ssh-context wrapper
# example:
ssh-context wrapper -vv user@server
```**Connect with another context**
```bash
ssh-context wrapper
# example:
ssh-context wrapper anotherproject server
```