@howdoi-cli/ssh 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/data/ssh/ssh-agent.yaml +46 -0
- package/data/ssh/ssh-config.yaml +53 -0
- package/data/ssh/ssh-keygen.yaml +49 -0
- package/data/ssh/ssh.yaml +50 -0
- package/package.json +35 -0
- package/postinstall.mjs +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 howdoi-cli contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @howdoi-cli/ssh
|
|
2
|
+
|
|
3
|
+
**howdoi knowledge base — ssh commands.**
|
|
4
|
+
|
|
5
|
+
Part of the [howdoi](https://github.com/SiphoChris/howdoi-cli) ecosystem.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @howdoi-cli/ssh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This also installs `@howdoi-cli/core` (the engine and `howdoi` binary) automatically.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
howdoi <what you want to do>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Install more knowledge bases
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g @howdoi-cli/unix
|
|
25
|
+
npm install -g @howdoi-cli/git
|
|
26
|
+
npm install -g @howdoi-cli/ssh
|
|
27
|
+
npm install -g @howdoi-cli/docker
|
|
28
|
+
npm install -g @howdoi-cli/networking
|
|
29
|
+
npm install -g @howdoi-cli/all
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
tool: ssh-agent
|
|
2
|
+
category: ssh
|
|
3
|
+
description: Manage the SSH authentication agent
|
|
4
|
+
package: "@howdoi-cli/ssh"
|
|
5
|
+
intents:
|
|
6
|
+
- add ssh key to agent
|
|
7
|
+
- ssh agent not found
|
|
8
|
+
- ssh-add key
|
|
9
|
+
- load ssh key
|
|
10
|
+
- start ssh agent
|
|
11
|
+
- fix ssh agent not running
|
|
12
|
+
- ssh agent forwarding
|
|
13
|
+
- list loaded ssh keys
|
|
14
|
+
- remove key from agent
|
|
15
|
+
- clear all keys from agent
|
|
16
|
+
- fix permission denied publickey
|
|
17
|
+
- ssh key not being used
|
|
18
|
+
examples:
|
|
19
|
+
- intent: start ssh agent
|
|
20
|
+
title: Start the SSH agent in current shell
|
|
21
|
+
command: eval "$(ssh-agent -s)"
|
|
22
|
+
- intent: add ssh key to agent
|
|
23
|
+
title: Add your default SSH key to the agent
|
|
24
|
+
command: ssh-add ~/.ssh/id_rsa
|
|
25
|
+
- intent: add ssh key to agent
|
|
26
|
+
title: Add an Ed25519 key (recommended key type)
|
|
27
|
+
command: ssh-add ~/.ssh/id_ed25519
|
|
28
|
+
- intent: add ssh key to agent
|
|
29
|
+
title: Add key and save passphrase to macOS keychain
|
|
30
|
+
command: ssh-add --apple-use-keychain ~/.ssh/id_ed25519
|
|
31
|
+
os: macos-only
|
|
32
|
+
- intent: list loaded ssh keys
|
|
33
|
+
title: List all keys currently loaded in the agent
|
|
34
|
+
command: ssh-add -l
|
|
35
|
+
- intent: remove key from agent
|
|
36
|
+
title: Remove a specific key from the agent
|
|
37
|
+
command: ssh-add -d ~/.ssh/id_ed25519
|
|
38
|
+
- intent: clear all keys from agent
|
|
39
|
+
title: Remove all keys from the agent
|
|
40
|
+
command: ssh-add -D
|
|
41
|
+
- intent: fix ssh agent not running
|
|
42
|
+
title: Fix "Could not open a connection to your authentication agent"
|
|
43
|
+
command: eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519
|
|
44
|
+
- intent: ssh agent forwarding
|
|
45
|
+
title: Connect with agent forwarding enabled
|
|
46
|
+
command: ssh -A user@host
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
tool: ssh config
|
|
2
|
+
category: ssh
|
|
3
|
+
description: Manage SSH client configuration file (~/.ssh/config)
|
|
4
|
+
package: "@howdoi-cli/ssh"
|
|
5
|
+
intents:
|
|
6
|
+
- configure ssh alias
|
|
7
|
+
- create ssh shortcut
|
|
8
|
+
- set default ssh key for host
|
|
9
|
+
- edit ssh config
|
|
10
|
+
- add host to ssh config
|
|
11
|
+
- set ssh config for github
|
|
12
|
+
- use different key per host
|
|
13
|
+
- view ssh config
|
|
14
|
+
examples:
|
|
15
|
+
- intent: edit ssh config
|
|
16
|
+
title: Open the SSH config file for editing
|
|
17
|
+
command: nano ~/.ssh/config
|
|
18
|
+
- intent: view ssh config
|
|
19
|
+
title: View the SSH config file
|
|
20
|
+
command: cat ~/.ssh/config
|
|
21
|
+
- intent: configure ssh alias
|
|
22
|
+
title: Example host entry with alias (add to ~/.ssh/config)
|
|
23
|
+
command: |
|
|
24
|
+
Host myserver
|
|
25
|
+
HostName 192.168.1.100
|
|
26
|
+
User ubuntu
|
|
27
|
+
IdentityFile ~/.ssh/id_ed25519
|
|
28
|
+
Port 22
|
|
29
|
+
- intent: set ssh config for github
|
|
30
|
+
title: GitHub-specific SSH config entry
|
|
31
|
+
command: |
|
|
32
|
+
Host github.com
|
|
33
|
+
HostName github.com
|
|
34
|
+
User git
|
|
35
|
+
IdentityFile ~/.ssh/id_ed25519
|
|
36
|
+
- intent: use different key per host
|
|
37
|
+
title: Use a different key for work vs personal GitHub
|
|
38
|
+
command: |
|
|
39
|
+
Host github-work
|
|
40
|
+
HostName github.com
|
|
41
|
+
User git
|
|
42
|
+
IdentityFile ~/.ssh/id_work
|
|
43
|
+
|
|
44
|
+
Host github-personal
|
|
45
|
+
HostName github.com
|
|
46
|
+
User git
|
|
47
|
+
IdentityFile ~/.ssh/id_personal
|
|
48
|
+
- intent: keep ssh connection alive
|
|
49
|
+
title: Global keep-alive setting in config
|
|
50
|
+
command: |
|
|
51
|
+
Host *
|
|
52
|
+
ServerAliveInterval 60
|
|
53
|
+
ServerAliveCountMax 3
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
tool: ssh-keygen
|
|
2
|
+
category: ssh
|
|
3
|
+
description: Generate and manage SSH key pairs
|
|
4
|
+
package: "@howdoi-cli/ssh"
|
|
5
|
+
intents:
|
|
6
|
+
- generate ssh key
|
|
7
|
+
- create ssh key pair
|
|
8
|
+
- make new ssh key
|
|
9
|
+
- generate ed25519 key
|
|
10
|
+
- generate rsa key
|
|
11
|
+
- create ssh key for github
|
|
12
|
+
- add passphrase to ssh key
|
|
13
|
+
- change ssh key passphrase
|
|
14
|
+
- view ssh public key
|
|
15
|
+
- copy ssh public key
|
|
16
|
+
- check ssh key fingerprint
|
|
17
|
+
- remove host from known hosts
|
|
18
|
+
- fix host key verification failed
|
|
19
|
+
examples:
|
|
20
|
+
- intent: generate ssh key
|
|
21
|
+
title: Generate a new Ed25519 key (recommended)
|
|
22
|
+
command: ssh-keygen -t ed25519 -C "your@email.com"
|
|
23
|
+
- intent: generate rsa key
|
|
24
|
+
title: Generate a 4096-bit RSA key
|
|
25
|
+
command: ssh-keygen -t rsa -b 4096 -C "your@email.com"
|
|
26
|
+
- intent: generate ssh key
|
|
27
|
+
title: Generate key with a specific filename
|
|
28
|
+
command: ssh-keygen -t ed25519 -f ~/.ssh/my_key -C "work laptop"
|
|
29
|
+
- intent: view ssh public key
|
|
30
|
+
title: Print your public key (to copy to GitHub, servers etc.)
|
|
31
|
+
command: cat ~/.ssh/id_ed25519.pub
|
|
32
|
+
- intent: check ssh key fingerprint
|
|
33
|
+
title: Show the fingerprint of a key
|
|
34
|
+
command: ssh-keygen -lf ~/.ssh/id_ed25519
|
|
35
|
+
- intent: change ssh key passphrase
|
|
36
|
+
title: Change the passphrase on an existing key
|
|
37
|
+
command: ssh-keygen -p -f ~/.ssh/id_ed25519
|
|
38
|
+
- intent: remove host from known hosts
|
|
39
|
+
title: Remove a host from known_hosts (fix host key errors)
|
|
40
|
+
command: ssh-keygen -R hostname
|
|
41
|
+
- intent: fix host key verification failed
|
|
42
|
+
title: Remove stale host key and reconnect
|
|
43
|
+
command: ssh-keygen -R hostname && ssh user@hostname
|
|
44
|
+
- intent: copy ssh public key
|
|
45
|
+
title: Copy public key to a remote server
|
|
46
|
+
command: ssh-copy-id user@hostname
|
|
47
|
+
- intent: copy ssh public key
|
|
48
|
+
title: Copy a specific public key to a remote server
|
|
49
|
+
command: ssh-copy-id -i ~/.ssh/id_ed25519.pub user@hostname
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
tool: ssh
|
|
2
|
+
category: ssh
|
|
3
|
+
description: Connect to remote servers securely
|
|
4
|
+
package: "@howdoi-cli/ssh"
|
|
5
|
+
intents:
|
|
6
|
+
- connect to remote server
|
|
7
|
+
- ssh into server
|
|
8
|
+
- login to remote machine
|
|
9
|
+
- connect with specific key
|
|
10
|
+
- connect on different port
|
|
11
|
+
- run command on remote server
|
|
12
|
+
- ssh tunnel
|
|
13
|
+
- port forward over ssh
|
|
14
|
+
- local port forwarding
|
|
15
|
+
- remote port forwarding
|
|
16
|
+
- copy file over ssh
|
|
17
|
+
- keep ssh connection alive
|
|
18
|
+
- connect with verbose output
|
|
19
|
+
- debug ssh connection
|
|
20
|
+
examples:
|
|
21
|
+
- intent: connect to remote server
|
|
22
|
+
title: Basic SSH connection
|
|
23
|
+
command: ssh user@hostname
|
|
24
|
+
- intent: connect with specific key
|
|
25
|
+
title: Connect using a specific identity file
|
|
26
|
+
command: ssh -i ~/.ssh/id_ed25519 user@hostname
|
|
27
|
+
- intent: connect on different port
|
|
28
|
+
title: Connect to a non-standard port
|
|
29
|
+
command: ssh -p 2222 user@hostname
|
|
30
|
+
- intent: run command on remote server
|
|
31
|
+
title: Run a single command on a remote server
|
|
32
|
+
command: ssh user@hostname "ls -la /var/log"
|
|
33
|
+
- intent: local port forwarding
|
|
34
|
+
title: Forward local port 8080 to remote port 80
|
|
35
|
+
command: ssh -L 8080:localhost:80 user@hostname
|
|
36
|
+
- intent: remote port forwarding
|
|
37
|
+
title: Expose local port 3000 on the remote server
|
|
38
|
+
command: ssh -R 9090:localhost:3000 user@hostname
|
|
39
|
+
- intent: ssh tunnel
|
|
40
|
+
title: Create a SOCKS proxy tunnel
|
|
41
|
+
command: ssh -D 1080 user@hostname
|
|
42
|
+
- intent: keep ssh connection alive
|
|
43
|
+
title: Keep connection alive with heartbeat
|
|
44
|
+
command: ssh -o ServerAliveInterval=60 user@hostname
|
|
45
|
+
- intent: connect with verbose output
|
|
46
|
+
title: Debug connection issues with verbose output
|
|
47
|
+
command: ssh -v user@hostname
|
|
48
|
+
- intent: connect to remote server
|
|
49
|
+
title: Connect and jump through a bastion host
|
|
50
|
+
command: ssh -J bastion-user@bastion user@target
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@howdoi-cli/ssh",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SSH knowledge base for howdoi — keys, agent, config, tunnels, and more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"data",
|
|
8
|
+
"postinstall.mjs",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "node postinstall.mjs",
|
|
14
|
+
"publish:npm": "npm publish"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"howdoi": {
|
|
20
|
+
"type": "knowledge-base",
|
|
21
|
+
"dataDir": "data"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@howdoi-cli/core": "^1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": ["cli", "ssh", "terminal", "howdoi"],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/SiphoChris/howdoi-cli"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, mkdirSync, existsSync, readFileSync } from "fs";
|
|
3
|
+
import { join, dirname, resolve } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
|
|
6
|
+
// process.argv[1] is always the path of the running script — reliable across
|
|
7
|
+
// all package managers and working directories
|
|
8
|
+
const scriptDir = dirname(resolve(process.argv[1]));
|
|
9
|
+
const pkgJsonPath = join(scriptDir, "package.json");
|
|
10
|
+
|
|
11
|
+
if (!existsSync(pkgJsonPath)) {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
16
|
+
const pkgName = pkgJson.name.replace("@howdoi-cli/", "");
|
|
17
|
+
|
|
18
|
+
// Skip in monorepo dev context — check for workspace root two levels up
|
|
19
|
+
const monoRootPkg = resolve(scriptDir, "..", "..", "package.json");
|
|
20
|
+
if (existsSync(monoRootPkg)) {
|
|
21
|
+
try {
|
|
22
|
+
const root = JSON.parse(readFileSync(monoRootPkg, "utf-8"));
|
|
23
|
+
if (root.workspaces) {
|
|
24
|
+
console.log(`[howdoi] Dev mode — skipping XDG install for ${pkgJson.name}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
} catch { /* continue */ }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const srcData = join(scriptDir, "data");
|
|
31
|
+
if (!existsSync(srcData)) {
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const xdgBase = process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share");
|
|
36
|
+
const dest = join(xdgBase, "howdoi", pkgName);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
mkdirSync(dest, { recursive: true });
|
|
40
|
+
cpSync(srcData, dest, { recursive: true });
|
|
41
|
+
console.log(`[howdoi] ✓ ${pkgJson.name}@${pkgJson.version} → ${dest}`);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.warn(`[howdoi] Warning: could not copy data: ${err.message}`);
|
|
44
|
+
console.warn(`[howdoi] howdoi will still work via node_modules fallback.`);
|
|
45
|
+
}
|