chinayin/coding-skillhub

gen-ssh-key

Generate SSH keys per team standards and return the public key.

查看源码

使用方法

  1. 复制安装命令,在自己的智能体环境安装前先检查源码包。
  2. 从原始文档核对所需工具、凭据和支持的宿主。
  3. 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/chinayin/coding-skillhub --skill gen-ssh-key

开始前需了解

  • 安装不包含模型订阅、API 额度或访问文件的权限。
  • 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Generate SSH Keys (Team Standard)

Run one script to produce a standards-compliant SSH key; do not hand-roll ssh-keygen commands. The script bakes in the team rules (key type, naming, permissions, overwrite guard), so using it is what guarantees compliance.

Workflow

  1. Derive <name> from the service or purpose the user mentions

(e.g. "jumpserver", "gitlab"). Kebab-case; no spaces or slashes.

  1. Pick flags from the request:
  • RSA explicitly requested: add --rsa (always RSA 4096; the script

refuses to produce RSA 2048, which the team bans as too weak).

  • Passphrase wanted: write the passphrase to a temporary file, pass

--passphrase-file <file>, and delete the file afterwards. Never put a passphrase on the command line.

  • Machine-readable result wanted (or another program consumes it): add

--json (pure JSON on stdout; diagnostics stay on stderr).

  • The user named a destination: add --out-dir <dir> (this may be the

current directory, e.g. --out-dir .), and keys go straight there. Otherwise, when neither --out-dir nor the skill's .env (SSH_KEY_OUTPUT_DIR) is set, keys go to the default ~/.ssh/generated-keys.

  1. Run the script from the skill directory:
bash
   ./scripts/gen-ssh-key.sh <name> [flags]
  1. Report back: give the user the public key content (it is safe to share)

and the file paths. Never print, quote, or transmit the private key contents, and never write the passphrase into results or logs — the JSON output intentionally carries only passphrase_protected: true.

If the target files already exist the script refuses; ask the user before retrying with --force.

Examples

bash
./scripts/gen-ssh-key.sh jumpserver                       # Ed25519 -> jumpserver.{ppk,pem,pub}
./scripts/gen-ssh-key.sh gitlab --rsa                     # RSA 4096
./scripts/gen-ssh-key.sh svc-x --passphrase-file ./pp.txt --json
./scripts/gen-ssh-key.sh jumpserver --out-dir ~/.ssh/generated-keys
./scripts/gen-ssh-key.sh jumpserver --comment "you@example.com"
./scripts/gen-ssh-key.sh jumpserver --dry-run             # show the plan only
./scripts/gen-ssh-key.sh --tool ssh-keygen jumpserver     # skip puttygen
./scripts/gen-ssh-key.sh -h                               # full flag reference

Team rules baked into the script

  • Key type: Ed25519 by default; --rsa means RSA 4096; RSA 2048 never.
  • Tool: puttygen preferred (adds .ppk for PuTTY users); ssh-keygen fallback.
  • Naming: <name>.ppk / .pem / .pub so keys are identifiable by service.
  • Comment -C defaults to <name>; override with --comment.
  • Private key chmod 600; newly created output directories chmod 700.
  • Overwrite refused by default; --force required.

Configuration

Output directory precedence: --out-dir > SSH_KEY_OUTPUT_DIR in .env (at the skill root, one level above scripts/) > the built-in default ~/.ssh/generated-keys. When both --out-dir and .env are absent, keys go to that default rather than the current directory (so they never silently land in the skill directory); pass --out-dir . if you do want the current directory. To change the default persistently, cp .env.example .env at the skill root and point SSH_KEY_OUTPUT_DIR elsewhere.

Artifacts

FilePurpose
<name>.ppkPuTTY-native key (puttygen path only)
<name>.pemOpenSSH private key (chmod 600, keep secret)
<name>.pubOpenSSH public key (share this; import / authorized_keys)

Exit codes

0 success; 1 bad argument, target exists, or generation failed; 2 no usable tool (neither puttygen nor ssh-keygen installed).

按任务相关推荐