{"id":44709483,"url":"https://github.com/cnlubo/myssh","last_synced_at":"2026-02-15T11:47:11.876Z","repository":{"id":37413327,"uuid":"195363641","full_name":"cnlubo/myssh","owner":"cnlubo","description":"sshtools","archived":false,"fork":false,"pushed_at":"2023-12-18T22:40:52.000Z","size":3866,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T17:43:38.238Z","etag":null,"topics":["ssh-key-manager","ssh-manager"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnlubo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-05T07:44:35.000Z","updated_at":"2024-06-20T17:43:38.238Z","dependencies_parsed_at":"2023-01-19T11:15:12.395Z","dependency_job_id":null,"html_url":"https://github.com/cnlubo/myssh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cnlubo/myssh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnlubo%2Fmyssh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnlubo%2Fmyssh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnlubo%2Fmyssh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnlubo%2Fmyssh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnlubo","download_url":"https://codeload.github.com/cnlubo/myssh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnlubo%2Fmyssh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29476903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T11:35:25.641Z","status":"ssl_error","status_checked_at":"2026-02-15T11:34:57.128Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ssh-key-manager","ssh-manager"],"created_at":"2026-02-15T11:47:11.357Z","updated_at":"2026-02-15T11:47:11.871Z","avatar_url":"https://github.com/cnlubo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n * @Author: cnak47\n * @Date: 2019-08-20 22:17:29\n * @LastEditors: cnak47\n * @LastEditTime: 2019-08-21 16:19:37\n * @Description: \n --\u003e\n\n# myssh\n\n使用 Go 编写的服务器SSH管理工具,主要将[sshbatch](https://github.com/agentzh/sshbatch)、[mmh](https://github.com/mritd/mmh)、[skm](https://github.com/TimothyYe/skm)、[manssh](https://github.com/xwjdsh/manssh)这几个工具的功能整合到一起以方便使用,部分代码拷贝自这几个工具。\n\n## 安装\n\n可直接从 [release](https://github.com/cnlubo/myssh/releases) 页下载预编译的二进制文件，然后执行 myssh install 安装,卸载直接执行 myssh uninstall,卸载命令不会删除 ~/.myssh 配置目录。\n\n## 基本命令\n\n```bash\nmyssh -h\n\nMy ssh toolkit. Flags and arguments can be input to do what actually you wish.\n\nUsage:\n  myssh [flags]\n  myssh [command]\n\nAvailable Commands:\n  km          manage ssh key (alias: mkm)\n  cfg         manage myssh configfile (alias: mcfg)\n  clusters    manage clusters (alias: mclusters)\n  alias       managing your ssh alias config (alias: malias)\n  install     install myssh\n  uninstall   uninstall myssh\n  backup      Backup all config,SSHKeys...\n  version     Print versions about Myssh\n\nFlags:\n      --no-color            Disable color when outputting message.\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n  -h, --help                help for myssh\n\nUse \"myssh [command] --help\" for more information about a command.\n\n```\n\n部分命令安装后自动软连接为快捷命令以便方便使用。\n\n- myssh alias ==\u003e malias\n- myssh cfg ==\u003e mcfg\n- myssh km  ==\u003e mkm\n- myssh clusters ==\u003e mclusters\n\n## SSH Keys Manager\n\n管理 多个 SSH Keys\n\n```bash\nManage multiple SSH keys\n\nUsage:\n  myssh km\n  myssh km [command]\n\nAliases:\n  km, mkm\n\nAvailable Commands:\n  init        Initialize SSH keys store\n  list        List all available SSH keys (alias:ls)\n  add         add one SSHKey\n  delete      delete SSH key (alias:del)\n  use         Set specific SSH key as default\n  display     Display SSHKey (alias:dp)\n  rename      Rename SSH key aliasName (alias:rn)\n  copy        Copy SSH public key to a remote host (alias:cp)\n\nFlags:\n  -h, --help   help for km\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n\nUse \"myssh km [command] --help\" for more information about a command.\n\n```\n\n![mkm](https://github.com/cnlubo/myssh/blob/master/snapshots/mkm.gif)\n\n### 初始化 SSH Key Store\n\n第一次运行时需要初始化 SSH Key Store\n\n```bash\nmkm init\n```\n\n所有的 SSH keys 都存储在 \\$HOME/.mkm目录中,如果$HOME/.ssh目录下存在 id_rsa \u0026 id_rsa.pub key pairs 将被移动到\\$HOME/.mkm/default.\n\n### 创建 SSH key\n\n当前支持 RSA 和 ED25519 两种类型的SSH key\n\n## 管理配置文件\n\n```bash\nmcfg -h\nmanage myssh ConfigFile.\n\nUsage:\n  myssh cfg\n  myssh cfg [command]\n\nAliases:\n  cfg, mcfg\n\nAvailable Commands:\n  list        List config (alias:ls)\n  add         Add context config\n  delete      delete config\n  set         set current config\n\nFlags:\n  -h, --help   help for cfg\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n\nUse \"myssh cfg [command] --help\" for more information about a command.\n```\n\n![mcfg](https://github.com/cnlubo/myssh/blob/master/snapshots/mcfg.gif)\n\n### 配置文件\n\n支持多配置文件切换功能,安装完成后将会自动在$HOME/.myssh下创建默认配置，默认配置文件结构如下:\n\n```bash\ntree ~/.myssh\n/Users/ak47/.myssh\n├── contexts\n│   ├── ak47\n│   │   ├── ak47.yaml\n│   │   ├── include\n│   │   └── sshconfig\n│   └── default\n│       ├── default.yaml\n│       ├── include\n│       │   └── k8s\n│       └── sshconfig\n└── main.yaml\n```\n\n#### main.yaml\n\n主配置文件结构如下:\n\n```bash\nbasic: default\ncontexts:\n- name: ak47\n  sshconfig: /Users/ak47/.myssh/contexts/ak47/sshconfig\n  clusterCfg: /Users/ak47/.myssh/contexts/ak47/ak47.yaml\n- name: default\n  sshconfig: /Users/ak47/.myssh/contexts/default/sshconfig\n  clusterCfg: /Users/ak47/.myssh/contexts/default/default.yaml\ncurrent: default\n```\n\n配置文件中可以配置多个context,由current字段指明当前使用哪个context.\n\n#### sshconfig\n\n默认内容如下:\n\n```bash\nInclude include/*\n```\n\n当前使用的context的 sshconfig 会被软连接到 ~/.ssh/config文件。可以使用 malias 命令 管理此配置文件。\n\n#### clusterCfg\n\n默认内容如下:\n\n```bash\ndefault:\n  user: ak47\n  privateKey: /Users/ak47/.ssh/id_ed25519\n  port: 22\n  server_alive_interval: 30s\nclusters: []\n```\n文件名一般与context名称相同,可以使用mclusters 命令来管理此配置文件.\n\n## 管理 SSH alias config\n\n```bash\nmalias -h\ncommand line tool for managing your ssh alias config.\n\nUsage:\n  myssh alias\n  myssh alias [command]\n\nAliases:\n  alias, malias\n\nAvailable Commands:\n  list        List ssh alias (alias:ls)\n  delete      Delete ssh alias (alias:del)\n  add         Add one ssh alias\n  update      Update ssh alias\n  batch       batch exec command (alias: bt)\n  go          ssh login Server\n  keycopy     Copy SSH public key to a alias Host (alias:kcp)\n\nFlags:\n  -h, --help   help for alias\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n\nUse \"myssh alias [command] --help\" for more information about a command.\n```\n### 创建 SSH alias\n\n```bash\nmalias add\n```\n\n![malias-add](https://github.com/cnlubo/myssh/blob/master/snapshots/malias-add.gif)\n\n### 查询 SSH alias\n\n![malias-list](https://github.com/cnlubo/myssh/blob/master/snapshots/malias-list.gif)\n\n支持模糊查询，例如:malias ls test\n\n### 删除 one or more alias\n\n```bash\nmalias del test test-1\n✔ deleted successfully!!!\n```\n### 修改 SSH alias\n\n```bash\nmalias update test3\n```\n![malias-update](https://github.com/cnlubo/myssh/blob/master/snapshots/malias-update.gif)\n\n\n### 拷贝 SSH public key to a alias Host\n\n```bash\nCopy SSH public key to alias Host\n\nUsage:\n  myssh alias keycopy alias...\n\nAliases:\n  keycopy, kcp\n\nFlags:\n  -h, --help   help for keycopy\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n```\n\n![malias-kcp](https://github.com/cnlubo/myssh/blob/master/snapshots/malias-kcp.gif)\n\n### 快捷登录服务器\n\n```bash\nmalias go test1\n```\n### 批量执行命令\n\n```bash\nmalias bt -h\nBatch exec command for alias.\n\nUsage:\n  myssh alias batch alias command ... [flags]\n\nAliases:\n  batch, bt\n\nFlags:\n  -h, --help     help for batch\n  -P, --prompt   Prompt for password\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n```\n![malias-batch](https://github.com/cnlubo/myssh/blob/master/snapshots/malias-btach.gif)\n\n\n## manage clusters\n\n整合了[sshbatch](https://github.com/agentzh/sshbatch)的相关功能,具体使用方法参考[sshbatch](https://github.com/agentzh/sshbatch).\n\n```bash\nmclusters -h\nmanage clusters.\n\nUsage:\n  myssh clusters\n  myssh clusters [command]\n\nAliases:\n  clusters, mclusters\n\nAvailable Commands:\n  parse       parse hostPattern to host list (alias:pa)\n  add         Add one cluster\n  list        List all cluster (alias:ls)\n  delete      delete cluster (alias:del)\n  batch       batch exec command (alias: bt)\n  keycopy     Copy public key to cluster (alias: kcp)\n\nFlags:\n  -h, --help   help for clusters\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n\nUse \"myssh clusters [command] --help\" for more information about a command.\n```\n### 解析 Host pattern to machine host list\n\n参考 [sshbatch](https://github.com/agentzh/sshbatch)中的fornodes脚本的使用方法，支持集合操作.\n\n```bash\nmclusters ls\n\n   CLUSTERNAME              HOSTPATTERN\n ---------------- --------------------------------\n  A                foo[01-03].com bar.org\n  B                bar.org baz[a-b,d,e-g].cn\n                   foo02.com\n  C                {A} * {B}\n  D                {A} - {B}\n\n```\n![mclusters](https://github.com/cnlubo/myssh/blob/master/snapshots/mclusters-1.gif)\n\n### 管理 clusters\n\n```bash\nmclusters add\nmclusters ls\nmclusters del\n```\n![mclusters-manage](https://github.com/cnlubo/myssh/blob/master/snapshots/mclusters-manage.gif)\n\n### 批量执行命令\n\n```bash\nmclusters bt -h\nBatch exec command for cluster.\n\nUsage:\n  myssh clusters batch hostPatterns command ... [flags]\n\nAliases:\n  batch, bt\n\nFlags:\n  -h, --help                  help for batch\n  -i, --identityfile string   identity file (private key) for public key authentication.\n  -P, --password              Prompt for password\n  -p, --port int              Port for the remote SSH service (default 22)\n  -u, --user string           User account for SSH login\n\nGlobal Flags:\n      --configPath string   Path where store myssh profiles.\n                            can also be set by the MYSSH_CONFIG_HOME environment variable. (default \"/Users/ak47/.myssh\")\n      --mkmPath string      Path where myssh should store multi SSHKeys.\n                            can also be set by the MKM_PATH environment variable. (default \"/Users/ak47/.mkm\")\n      --no-color            Disable color when outputting message.\n      --sshPath string      Path to .ssh folder.\n                            can also be set by the SSH_PATH environment variable. (default \"/Users/ak47/.ssh\")\n```\n![mclusters-batch](https://github.com/cnlubo/myssh/blob/master/snapshots/mclusters-batch.gif)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnlubo%2Fmyssh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnlubo%2Fmyssh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnlubo%2Fmyssh/lists"}