package module
Version: v0.5.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 7 Imported by: 1



Release Build Status Go Report Card GoDoc DUB

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

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.



go get -u
brew tap xwjdsh/tap
brew install xwjdsh/tap/manssh
alias manssh='docker run -t --rm -v ~/.ssh/config:/root/.ssh/config wendellsun/manssh'

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


% manssh
   manssh - Manage your ssh alias configs easily

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


     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

   --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
# manssh add test1 root@ -c IdentityFile=~/.ssh/wendell
% manssh add test1 root@ -i ~/.ssh/wendell
✔ alias[test1] added successfully.

        test1 -> root@
                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 -> root@
                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 root@
% manssh update test1 -i "" -r test3 -c hostname= -c port=22022
✔ alias[test3] updated successfully.

        test3 -> root@

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.


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.


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



MIT License




This section is empty.


This section is empty.


func GetFilePaths added in v0.5.1

func GetFilePaths(p string) ([]string, error)

GetFilePaths get file paths


type AddOption added in v0.5.0

type AddOption struct {
	// Path add path
	Path string
	// Alias alias
	Alias string
	// Connect connection string
	Connect string
	// Config other config
	Config map[string]string

AddOption options for Add

type HostConfig added in v0.3.0

type HostConfig struct {
	// Alias alias
	Alias string
	// Path found in which file
	Path string
	// PathMap key is file path, value is the alias's hosts
	PathMap map[string][]*ssh_config.Host
	// OwnConfig own config
	OwnConfig map[string]string
	// ImplicitConfig implicit config
	ImplicitConfig map[string]string

HostConfig struct include alias, connect string and other config

func Add added in v0.3.0

func Add(p string, ao *AddOption) (*HostConfig, error)

Add ssh host config to ssh config file

func Delete added in v0.3.0

func Delete(p string, aliases ...string) ([]*HostConfig, error)

Delete existing alias record

func List added in v0.3.0

func List(p string, lo ListOption) ([]*HostConfig, error)

List ssh alias, filter by optional keyword

func NewHostConfig added in v0.5.0

func NewHostConfig(alias, path string, host *ssh_config.Host) *HostConfig

NewHostConfig new HostConfig

func Update added in v0.3.0

func Update(p string, uo *UpdateOption) (*HostConfig, error)

Update existing record

func (*HostConfig) ConnectionStr added in v0.5.1

func (hc *HostConfig) ConnectionStr() string

ConnectionStr return the connection string

func (*HostConfig) Display added in v0.5.0

func (hc *HostConfig) Display() bool

Display Whether to display connection string

type ListOption added in v0.5.0

type ListOption struct {
	// Keywords set Keyword filter records
	Keywords []string
	// IgnoreCase ignore case
	IgnoreCase bool

ListOption options for List

type UpdateOption added in v0.5.0

type UpdateOption struct {
	// Alias alias
	Alias string
	// NewAlias new alias
	NewAlias string
	// Connect connection string
	Connect string
	// Config other config
	Config map[string]string

UpdateOption options for Update

func (*UpdateOption) Valid added in v0.5.0

func (uo *UpdateOption) Valid() bool

Valid whether the option is valid


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL