gssh
v0.1.3
Published
SSH + Git author profile manager
Readme
gssh - SSH + Git Author Profile Manager
A cross-platform Node.js CLI tool that manages multiple SSH keys and Git author profiles.
Features
- Profile-based SSH key management: Switch between different SSH identities with a single command
- Git author configuration: Automatically set Git user.name and user.email (global or local)
- Auto-import existing keys: Automatically detects and offers to import existing SSH keys on first run
- Public key display: Easily copy your public key to clipboard for GitHub/GitLab
- Cross-platform: Works on macOS, Linux, and Windows (Node.js 18+)
Installation
From Source
cd gssh-node
npm install
npm run build
# Install globally (optional)
npm linkFrom npm
npm install -g gsshUsage
List all profiles
gssh listCreate a new profile
gssh add myprofile
# Interactive wizard will prompt for Git author name, email, and generate SSH keySwitch to a profile
# Set Git config globally (default)
gssh use myprofile
# Set Git config locally (current repo only)
gssh use myprofile -lShow current active profile
gssh currentDisplay public key
gssh pubkey
# Automatically copies to clipboard (macOS/Linux/Windows)Remove a profile
gssh remove myprofile
# Safety checks prevent accidental deletion of active profileShow menu (default)
gssh
# Shows menu, current profile, and public keyHow It Works
Profile Storage
Profiles are stored in ~/.ssh/profiles/<profile-name>/:
~/.ssh/profiles/
├── work/
│ ├── id_ed25519 # Private key
│ ├── id_ed25519.pub # Public key
│ └── git_author.txt # Git author info
└── personal/
├── id_ed25519
├── id_ed25519.pub
└── git_author.txtActive Profile Tracking
Active profile is tracked using two methods:
- Marker file (preferred):
~/.ssh/git-ssh-active.txt - Public key matching (fallback): Compares public keys in
~/.ssh/with profile keys
Git Author Format
The git_author.txt file supports two formats:
Single line:
John Doe <[email protected]>Two lines:
John Doe
[email protected]Technical Details
Stack
- TypeScript with ESM modules
- commander - CLI parsing
- chalk - Terminal colors
- execa - Shell command execution
- fast-glob - Directory traversal
Architecture
src/
├── index.ts # Main entry point
├── cli.ts # Commander.js setup
├── types.ts # TypeScript interfaces
├── paths.ts # Filesystem path management
├── git-author.ts # Git config management
├── keypair.ts # SSH key operations
├── utils/
│ ├── clipboard.ts # Platform-specific clipboard
│ ├── prompts.ts # Interactive prompts
│ ├── errors.ts # Error handling
│ └── platform.ts # Platform detection
└── commands/
├── list.ts # List profiles
├── use.ts # Switch profiles
├── add.ts # Create profiles
├── remove.ts # Delete profiles
├── current.ts # Show active profile
├── pubkey.ts # Display public key
├── import.ts # Auto-import existing keys
├── menu.ts # Default menu
└── shared.ts # Shared utilitiesFile Permissions
On Unix-like systems (macOS, Linux):
- Private keys:
chmod 600(read-only by owner) - Public keys:
chmod 644(readable by all)
On Windows: Relies on NTFS permissions (not explicitly managed)
Clipboard Support
Platform-specific clipboard commands:
- macOS:
pbcopy - Windows:
clip - Linux:
xclip,xsel,wl-copy(tries multiple)
Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Watch mode (development)
npm run dev
# Clean build artifacts
npm run cleanDifferences from Rust Version
- Uses Node.js native
readlineinstead of external prompt libraries - Uses
execafor shell commands instead ofstd::process::Command - Modular file structure vs single-file binary
- Same CLI interface and functionality
Requirements
- Node.js 18 or higher
ssh-keygen(for generating keys)git(for setting config)
License
MIT
