sshya
v0.2.5
Published
CLI for managing SSH connections with aliases, interactive prompts, and fzf integration
Readme
Project: sshya
This project is a command-line interface (CLI) tool named sshya for managing SSH connections.
Core Functionality
- Add, remove, update, and list SSH connection configurations (alias, user, host, port, key path, remote path).
- Connect to saved connections with
sshya connect(aliases:ssh,go). - Copy files through saved connections with
sshya copy(aliases:sc,scp). - Generate SSH command strings for scripting with
sshya print. - Import and export connections from/to a JSON file.
- fzf-based launcher for fast, keyboard-driven connection selection.
Technology Stack
- Runtime: Bun
- Language: TypeScript
- Dependencies:
commander: For command-line argument parsing.inquirer: For interactive prompts.chalk: for terminal string styling.fuse.js: for fuzzy searching connections.zod: for validating user input and imported data.
Implementation Details
The main application logic is in index.ts. SSH arguments are built in-process and passed directly to your system ssh binary, avoiding fragile shell string parsing.
fzf-based launcher
You can enable a fast, keyboard-driven launcher for your saved connections using fzf.
Quick setup
Ensure
fzfis installed.Print the shell snippet:
sshya fzf # or the aliases sshya instructions sshya installCopy the printed snippet into your
~/.zshrcor~/.bashrcand reload your shell.
How it works
- The function displays your connections via
sshya list --oneline --names, showing alias and user@host. - After you pick an entry with
fzf, it runssshya connect <alias>. sshya connectbuilds SSH arguments in-process and spawns your systemsshwith inherited stdio, so TTY behavior matches typing the command yourself.
Usage
After adding the snippet to your shell rc and reloading, simply run:
sThis will launch the fzf interface for selecting and connecting to your saved SSH connections.
You can also connect directly without fzf:
sshya connect my-server
sshya connect # interactive pickerCopy files
Use stored connections for scp uploads and downloads:
sshya copy my-server ./local.txt /tmp/remote.txt
sshya copy ./local.txt /tmp/remote.txt # interactive connection picker
sshya copy --download my-server /tmp/remote.txt ./
sshya copy --recursive my-server ./dist /var/wwwThe copy command also works as sshya sc or sshya scp. For a short no-fzf wrapper:
sc() {
sshya copy "$@"
}Relative remote paths are resolved from the connection's saved remote working directory when one is configured.
If an exact alias is not found, connect and copy use the first fuzzy match from the same search used by the interactive picker.
Troubleshooting
- If fzf filtering looks wrong, reload your shell after updating the snippet. The launcher should call
sshya connect, not parsesshya printoutput. - If the port or key path is ignored, verify the connection with
sshya test <alias>.
