mine ssh
Manage SSH hosts, keys, and tunnels with ~/.ssh/config as the source of truth.
Fuzzy Host Picker
Section titled “Fuzzy Host Picker”mine sshOpens an interactive fuzzy-searchable list of configured SSH hosts. Select a host to connect. Falls back to a plain list when no TTY is detected (e.g. in scripts).
List Hosts
Section titled “List Hosts”mine ssh hostsLists all non-wildcard Host entries from ~/.ssh/config.
Add a Host
Section titled “Add a Host”mine ssh add myservermine ssh add # prompts for aliasInteractively generates a Host block and appends it to ~/.ssh/config. Prompts for:
- Alias — the name you’ll use to connect (
ssh myserver) - HostName — IP address or FQDN
- User — remote username
- Port — defaults to 22 (omitted from config if default)
- IdentityFile — path to SSH key (optional)
Remove a Host
Section titled “Remove a Host”mine ssh remove myserverCleanly removes the named Host block from ~/.ssh/config without corrupting the file.
Generate a Key
Section titled “Generate a Key”mine ssh keygen # creates ~/.ssh/id_ed25519mine ssh keygen deploy # creates ~/.ssh/deployGenerates an ed25519 SSH key pair with secure defaults and uses ssh-keygen under the hood. You’ll be prompted for a passphrase; using a strong passphrase is recommended to protect your private key at rest (leaving it empty is possible but discouraged).
Copy Key to Remote
Section titled “Copy Key to Remote”mine ssh copyid myserverCopies your default public key to a remote host using ssh-copy-id.
List Keys
Section titled “List Keys”mine ssh keysLists all SSH key pairs in ~/.ssh/ with:
- Fingerprint (SHA256)
- Which configured hosts use each key
- Path to the private key
Start a Tunnel
Section titled “Start a Tunnel”mine ssh tunnel myserver 8080:80 # local 8080 → remote 80mine ssh tunnel db 5433:5432 # local 5433 → remote 5432mine ssh tunnel db 5433:db.internal:5432 # local 5433 → db.internal:5432 via dbStarts an SSH port-forwarding tunnel in the foreground. Press Ctrl+C to stop. Uses ssh -N -L with ExitOnForwardFailure=yes.
The port spec supports two forms:
local:remotePort— forwards tolocalhost:remotePorton the remote hostlocal:remoteHost:remotePort— forwards to a specific host reachable from the SSH server
Shell Functions
Section titled “Shell Functions”The following SSH helper functions are included in mine shell init:
| Function | Description |
|---|---|
sc <alias> | Quick connect: ssh <alias> |
scp2 <src> <dest> | Resumable copy: rsync -avzP --partial over SSH |
stun <alias> <L:R> or stun <alias> <L:H:R> | Quick tunnel: ssh -N -L shorthand; supports local:remote and local:remoteHost:remote |
skey [file] | Copy default public key to clipboard |
All functions include --help for usage documentation and work in bash, zsh, and fish.
Usage examples
Section titled “Usage examples”# Connect to a hostsc myserver
# Copy files with progress and resumescp2 myserver:/var/log/app.log ./logs/
# Start a tunnel (local 8080 → remote 80)stun myserver 8080:80# Or with explicit remote host (local 5433 → db.internal:5432 via myserver)stun myserver 5433:db.internal:5432
# Copy your public key to clipboardskeyskey ~/.ssh/id_ed25519.pubHook Integration
Section titled “Hook Integration”Every mine ssh command fires hook events, allowing plugin hooks to intercept SSH workflows:
| Command | Hook name |
|---|---|
mine ssh | ssh |
mine ssh hosts | ssh.hosts |
mine ssh add | ssh.add |
mine ssh remove | ssh.remove |
mine ssh keygen | ssh.keygen |
mine ssh copyid | ssh.copyid |
mine ssh keys | ssh.keys |
mine ssh tunnel | ssh.tunnel |
See hooks for how to create and register hooks.
Examples
Section titled “Examples”# Set up a new servermine ssh add stagingmine ssh keygen stagingmine ssh copyid stagingsc staging
# Quick tunnel to a databasestun db 5433:5432
# Audit your keysmine ssh keys