Manage your ssh alias configs easily.

manssh

Release Build Status Go Report Card GoCover.io GoDoc DUB

manssh is a command line tool for managing your ssh alias config easily, inspired by storm project, powered by Go.

Note:
This project is actually a simple glue project, the most complex and core parsing ssh config file logic implements by ssh_config, I didn't do much.
At first it was just a imitation of storm, now it has become a little different.

Feature

Install

Gopher

go get -u github.com/xwjdsh/manssh/cmd/manssh

Homebrew

brew tap xwjdsh/tap
brew install xwjdsh/tap/manssh

Docker

alias manssh='docker run -t --rm -v ~/.ssh/config:/root/.ssh/config wendellsun/manssh'

Manual

Download it from releases, and extract it to your PATH directory.

Usage

% manssh
NAME:
   manssh - Manage your ssh alias configs easily

USAGE:
   manssh [global options] command [command options] [arguments...]

VERSION:
   master

COMMANDS:
     add, a     Add a new SSH alias record
     list, l    List or query SSH alias records
     update, u  Update SSH record by specifying alias name
     delete, d  Delete SSH records by specifying alias names
     backup, b  Backup SSH config files
     help, h    Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --file value, -f value  (default: "/Users/wendell/.ssh/config")
   --help, -h              show help
   --version, -v           print the version

Add a new alias

# manssh add test2 2.2.2.2
# manssh add test1 [email protected]:77 -c IdentityFile=~/.ssh/wendell
% manssh add test1 [email protected]:77 -i ~/.ssh/wendell
✔ alias[test1] added successfully.

        test1 -> [email protected]:77
                identityfile = /Users/wendell/.ssh/wendell

Username and port config is optional, the username is current login username and port is 22 by default.
Using -c to set more config options. For convenience, -i xxx can instead of -c identityfile=xxx.

List or query alias

# manssh list
# manssh list "*"
# manssh list Test -ic
% manssh list test1 77
✔ Listing 1 records.

        test1 -> [email protected]:77
                identityfile = /Users/wendell/.ssh/wendell

It will display all alias records If no params offered, or it will using params as keywords query alias records.
If there is a -it option, it will ignore case when searching.

Update an alias

# manssh update test1 -r test2
# manssh update test1 [email protected]:22022
% manssh update test1 -i "" -r test3 -c hostname=3.3.3.3 -c port=22022
✔ alias[test3] updated successfully.

        test3 -> [email protected]:22022

Update an existing alias record, it will replace origin user, hostname, port config's if connected string param offered.
You can use -c to update single and extra config option, -c identityfile= -c proxycommand= will remove identityfile and proxycommand options.
For convenience, -i xxx can instead of -c identityfile=xxx
Rename the alias specified by -r flag.

Delete one or more alias

# manssh delete test1
% manssh delete test1 test2
✔ alias[test1,test2] deleted successfully.

Backup ssh config

% manssh backup ./config_backup
✔ backup ssh config to [./config_backup] successfully.

For Include directive

If you use the Include directive, there are some extra notes.

Add -p(--path) flag for list,add,update,delete command to show the file path where the alias is located, it can also be set by the MANSSH_SHOW_PATH environment variable.

MANSSH_SHOW_PATH

Set to true to show the file path where the alias is located. Default is false.


Add -ap(--addpath) flag for add command to specify the file path to which the alias is added, it can also be set by the MANSSH_ADD_PATH environment variable.

MANSSH_ADD_PATH

This file path indicates to which file to add the alias. Default is the entry config file.


For convenience, you can export these environments in your .zshrc or .bashrc, example:

export MANSSH_SHOW_PATH=true
export MANSSH_ADD_PATH=~/.ssh/config.d/temp

Thanks

Licence

MIT License

Owner
Wendell Sun
The time you enjoy wasting is not wasted.
Wendell Sun
Similar Resources

Manage your dotfiles across multiple diverse machines, securely.

chezmoi Manage your dotfiles across multiple diverse machines, securely. With chezmoi, you can install chezmoi and your dotfiles on a new, empty machi

Dec 30, 2022

A tool that allows you to manage Kubernetes manifests for your services in a Git repository

kuberpult Readme for users About Kuberpult is a tool that allows you to manage Kubernetes manifests for your services in a Git repository and manage t

Dec 16, 2022

A software which can manage and analysis your hands played on GGPoker and Natural8

PokerManager PokerManagr is a software which can manage and analysis your hands played on GGPoker and Natural8 Related Installation Web server : Nginx

Apr 20, 2022

Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

StatusOK Monitor your Website and APIs from your computer.Get notified through Slack or E-mail when your server is down or response time is more than

Dec 27, 2022

:recycle: Now you can easily rollback to previous deployed images whatever you want on k8s environment

EasyRollback EasyRollback is aim to easy rollback to previous images that deployed on k8s environment Installation You should have go installation fir

Dec 24, 2022

The Elastalert Operator is an implementation of a Kubernetes Operator, to easily integrate elastalert with gitops.

Elastalert Operator for Kubernetes The Elastalert Operator is an implementation of a Kubernetes Operator. Getting started Firstly, learn How to use el

Jun 28, 2022

Topology-tester - Application to easily test microservice topologies and distributed tracing including K8s and Istio

Topology Tester The Topology Tester app allows you to quickly build a dynamic mi

Jan 14, 2022

Copy files and artifacts via SSH using a binary, docker or Drone CI.

drone-scp Copy files and artifacts via SSH using a binary, docker or Drone CI. Feature Support routines. Support wildcard pattern on source list. Supp

Dec 6, 2022

easyssh-proxy provides a simple implementation of some SSH protocol features in Go

easyssh-proxy easyssh-proxy provides a simple implementation of some SSH protocol features in Go. Feature This project is forked from easyssh but add

Dec 30, 2022
Comments
  • take `Include` directive into consideration

    take `Include` directive into consideration

    All my aliases are defined in different config files, using ssh_config Include directive.

    serge  minos  ~ 
    ➡  cat .ssh/config
    Include config.d/*
    
    serge  minos  ~ 
    ➡  manssh list
    ✔ Listing 0 records.
    
  • Add ssh_config.GetCanonicalCase to print correct key case

    Add ssh_config.GetCanonicalCase to print correct key case

    Adds canonical casing to print output, using the GetCanonicalCase func added in PRs to ssh_config

    Example:

    Host ssh.github.com gist.github.com github.com github
        Hostname ssh.github.com
        IdentitiesOnly yes
        IdentityFile ~/.ssh/id_ed25519
        User git
    

    gets displayed appropriately as:

    	gist.github.com(~/.ssh/config) -> [email protected]:22
    	    IdentitiesOnly = yes
    	    IdentityFile = ~/.ssh/id_ed25519
    
    	github(~/.ssh/config) -> [email protected]:22
    	    IdentitiesOnly = yes
    	    IdentityFile = ~/.ssh/id_ed25519
    
    	github.com(~/.ssh/config) -> [email protected]:22
    	    IdentitiesOnly = yes
    	    IdentityFile = ~/.ssh/id_ed25519
    
    	github.me(~/.ssh/config) -> [email protected]:22
    	    IdentitiesOnly = yes
    	    IdentityFile = ~/.ssh/id_ed25519
    
    	ssh.github.com(~/.ssh/config) -> [email protected]:22
    	    IdentitiesOnly = yes
    	    IdentityFile = ~/.ssh/id_ed25519
    

    TODO: Remove reference to github.com/StephenBrown2/ssh_config when https://github.com/kevinburke/ssh_config/pull/39 or https://github.com/xwjdsh/ssh_config/pull/1 get merged

  • panic: runtime error: invalid memory address or nil pointer dereference & SIGSEGV

    panic: runtime error: invalid memory address or nil pointer dereference & SIGSEGV

    Configuration

    OS: Ubuntu 16.04 go version: go1.10.2 linux/amd64

    Process I've done

    Then I do an install with

    go get -u github.com/xwjdsh/manssh/cmd/manssh
    

    and run the following

    manssh list
    

    It returns this error trace

    panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    	panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x52c814]
    
    goroutine 1 [running]:
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.decode.func1(0xc4200616e8)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/config.go:216 +0x1f2
    panic(0x579640, 0x68f8d0)
    	/usr/local/go/src/runtime/panic.go:502 +0x229
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.(*sshParser).parseKV(0xc4200be1e0, 0xc42009ff20)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/parser.go:99 +0x264
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.(*sshParser).(github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.parseKV)-fm(0xc42009ff20)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/parser.go:80 +0x2a
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.(*sshParser).run(0xc4200be1e0)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/parser.go:38 +0x42
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.parseSSH(0xc420094180, 0xc4200b0000, 0xc420094180)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/parser.go:180 +0x307
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.decode(0x5c7680, 0xc4200b8048, 0x0, 0x0, 0x0, 0x0)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/config.go:226 +0x90
    github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config.Decode(0x5c7680, 0xc4200b8048, 0x440, 0x180, 0xc4200b8048)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/xwjdsh/ssh_config/config.go:209 +0x3c
    github.com/xwjdsh/manssh.ParseConfig(0xc4200b6e20, 0x19, 0x0, 0x0)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/sshconfig.go:26 +0x78
    github.com/xwjdsh/manssh.List(0xc4200b6e20, 0x19, 0x6b3800, 0x0, 0x0, 0xc420061a77, 0x1, 0x1, 0x5, 0x4, ...)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/sshconfig.go:38 +0x6e
    main.list(0xc4200c42c0, 0x0, 0xc4200c42c0)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/cmd/manssh/actions.go:17 +0xe1
    github.com/xwjdsh/manssh/vendor/github.com/urfave/cli.HandleAction(0x570100, 0x5b1a18, 0xc4200c42c0, 0xc4200be100, 0x0)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/urfave/cli/app.go:490 +0xc8
    github.com/xwjdsh/manssh/vendor/github.com/urfave/cli.Command.Run(0x5a69d0, 0x4, 0x0, 0x0, 0xc42009e470, 0x1, 0x1, 0x5ac7f3, 0x1f, 0x0, ...)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/urfave/cli/command.go:210 +0xa36
    github.com/xwjdsh/manssh/vendor/github.com/urfave/cli.(*App).Run(0xc4200c04e0, 0xc4200aa020, 0x2, 0x2, 0x0, 0x0)
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/vendor/github.com/urfave/cli/app.go:255 +0x6a0
    main.main()
    	/home/thomasg/go/src/github.com/xwjdsh/manssh/cmd/manssh/main.go:21 +0x11c
    

    I also tried directly with the release file manssh_0.4.0_linux_amd64.tar.gz from https://github.com/xwjdsh/manssh/releases

  • Panic when trying to update existing config

    Panic when trying to update existing config

    Adding works fine:

    $ cat ~/.ssh/config
    $ manssh add github.com -c ControlMaster=auto -c ControlPath=~/.ssh/ssh-%r@%h:%p -c ControlPersist=yes -c User=git -c IdentityFile=~/.ssh/github_ssh_key_10_Mar_2020
    ✔  added successfully
    
    	github.com
    	    controlmaster = auto
    	    controlpath = /Users/petersouter/.ssh/ssh-%r@%h:%p
    	    controlpersist = yes
    	    identityfile = /Users/petersouter/.ssh/github_ssh_key_10_Mar_2020
    	    user = git
    	    port = 22
    

    But updating crashes and removes the entry:

    $ manssh update github.com -c ControlMaster=auto -c ControlPath=~/.ssh/ssh-%r@%h:%p -c ControlPersist=yes -c User=git -c IdentityFile=~/.ssh/github_ssh_key_10_Mar_2020
    ✔  updated successfully
    
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1159eaa]
    
    goroutine 1 [running]:
    main.printHost(0xc4200cc400, 0x0)
    	/Users/wendell/Working/GOPATH/src/github.com/xwjdsh/manssh/cmd/manssh/print.go:47 +0x3a
    main.updateCmd(0xc4200cc420, 0x0, 0xc4200cc420)
    	/Users/wendell/Working/GOPATH/src/github.com/xwjdsh/manssh/cmd/manssh/actions.go:110 +0x450
    github.com/xwjdsh/manssh/vendor/github.com/urfave/cli.HandleAction(0x1181000, 0x11c5958, 0xc4200cc420, 0xc420084100, 0x0)
    	/Users/wendell/Working/GOPATH/src/github.com/xwjdsh/manssh/vendor/github.com/urfave/cli/app.go:490 +0xc8
    github.com/xwjdsh/manssh/vendor/github.com/urfave/cli.Command.Run(0x11bac27, 0x6, 0x0, 0x0, 0xc420066560, 0x1, 0x1, 0x11c03e4, 0x1e, 0x0, ...)
    	/Users/wendell/Working/GOPATH/src/github.com/xwjdsh/manssh/vendor/github.com/urfave/cli/command.go:210 +0xa36
    github.com/xwjdsh/manssh/vendor/github.com/urfave/cli.(*App).Run(0xc4200a84e0, 0xc420010750, 0xd, 0xd, 0x0, 0x0)
    	/Users/wendell/Working/GOPATH/src/github.com/xwjdsh/manssh/vendor/github.com/urfave/cli/app.go:255 +0x6a0
    main.main()
    	/Users/wendell/Working/GOPATH/src/github.com/xwjdsh/manssh/cmd/manssh/main.go:21 +0x11c
    
Walker's alias method is an efficient algorithm to sample from a discrete probability distribution.

walker-alias Walker's alias method is an efficient algorithm to sample from a discrete probability distribution. This means given an arbitrary probabi

Jun 14, 2022
This is a SSH CA that allows you to retrieve a signed SSH certificate by authenticating to Duo.

github-duo-ssh-ca Authenticate to GitHub Enterprise in a secure way by requiring users to go through a Duo flow to get a short-lived SSH certificate t

Jan 7, 2022
Integrated ssh-agent for windows. (pageant compatible. openSSH ssh-agent etc ..)
Integrated ssh-agent for windows. (pageant compatible. openSSH ssh-agent etc ..)

OmniSSHAgent About The chaotic windows ssh-agent has been integrated into one program. Chaos Map of SSH-Agent on Windows There are several different c

Dec 19, 2022
Easily run your Compose application to the cloud with compose-cli

This CLI tool makes it easy to run Docker containers and Docker Compose applications in the cloud using either Amazon Elastic Container Service (ECS) or Microsoft Azure Container Instances (ACI) using the Docker commands you already know.

Jan 8, 2023
Managing your Kubernetes clusters (including public, private, edge, etc) as easily as visiting the Internet

Clusternet Managing Your Clusters (including public, private, hybrid, edge, etc) as easily as Visiting the Internet. Clusternet (Cluster Internet) is

Dec 30, 2022
Easily deploy your Go applications with Dokku.

dokku-go-example Easily deploy your Go applications with Dokku. Features: Deploy on your own server Auto deployment HTTPS Check the full step by step

Aug 21, 2022
Open URL in your local web browser from the SSH-connected remote environment.

opener Open URL in your local web browser from the SSH-connected remote environment. How does opener work? opener is a daemon process that runs locall

Oct 20, 2022
go-awssh is a developer tool to make your SSH to AWS EC2 instances easy.

Describing Instances/VPCs data, select one or multiple instances, and make connection(s) to selected instances. Caching the response of API calls for 1day using Tmpfs.

Oct 11, 2021
Jenkins CLI allows you manage your Jenkins as an easy way

Quick start 简体中文 Jenkins CLI Jenkins CLI allows you manage your Jenkins in an easy way. No matter if you're a plugin developer, administrator or just

Jan 4, 2023
🐶 Kubernetes CLI To Manage Your Clusters In Style!
🐶 Kubernetes CLI To Manage Your Clusters In Style!

K9s - Kubernetes CLI To Manage Your Clusters In Style! K9s provides a terminal UI to interact with your Kubernetes clusters. The aim of this project i

Jan 9, 2023