Skip to content

mine ssh

Manage SSH hosts, keys, and tunnels with ~/.ssh/config as the source of truth.

Terminal window
mine ssh

Opens 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).

Terminal window
mine ssh hosts

Lists all non-wildcard Host entries from ~/.ssh/config.

Terminal window
mine ssh add myserver
mine ssh add # prompts for alias

Interactively 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)
Terminal window
mine ssh remove myserver

Cleanly removes the named Host block from ~/.ssh/config without corrupting the file.

Terminal window
mine ssh keygen # creates ~/.ssh/id_ed25519
mine ssh keygen deploy # creates ~/.ssh/deploy

Generates 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).

Terminal window
mine ssh copyid myserver

Copies your default public key to a remote host using ssh-copy-id.

Terminal window
mine ssh keys

Lists all SSH key pairs in ~/.ssh/ with:

  • Fingerprint (SHA256)
  • Which configured hosts use each key
  • Path to the private key
Terminal window
mine ssh tunnel myserver 8080:80 # local 8080 → remote 80
mine ssh tunnel db 5433:5432 # local 5433 → remote 5432
mine ssh tunnel db 5433:db.internal:5432 # local 5433 → db.internal:5432 via db

Starts 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 to localhost:remotePort on the remote host
  • local:remoteHost:remotePort — forwards to a specific host reachable from the SSH server

The following SSH helper functions are included in mine shell init:

FunctionDescription
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.

Terminal window
# Connect to a host
sc myserver
# Copy files with progress and resume
scp2 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 clipboard
skey
skey ~/.ssh/id_ed25519.pub

Every mine ssh command fires hook events, allowing plugin hooks to intercept SSH workflows:

CommandHook name
mine sshssh
mine ssh hostsssh.hosts
mine ssh addssh.add
mine ssh removessh.remove
mine ssh keygenssh.keygen
mine ssh copyidssh.copyid
mine ssh keysssh.keys
mine ssh tunnelssh.tunnel

See hooks for how to create and register hooks.

Terminal window
# Set up a new server
mine ssh add staging
mine ssh keygen staging
mine ssh copyid staging
sc staging
# Quick tunnel to a database
stun db 5433:5432
# Audit your keys
mine ssh keys