sshc is a modern SSH configuration helper and manager written in Go. It helps you keep your main ~/.ssh/config clean by managing modular configuration files in a dedicated directory using the Include directive.
- Safe Initialization: Automatically backs up your existing SSH config and sets up the
Includedirective. - Modular Management: Keep separate config files for different projects or environments in
~/.ssh/sshc.d/. - Integrated Key Generation: Automatically generate RSA, Ed25519, or ECDSA keys when adding new configurations.
- Dry-run Support: Preview changes before applying them with the global
--dry-runor-nflag. - Git-like CLI: Intuitive commands like
add,rm,list,show, andedit.
Ensure you have Go 1.26 or later installed.
# Clone the repository
git clone https://github.com/jmpeax/sshc.git
cd sshc
# Build and install
make build
sudo cp bin/sshc /usr/local/bin/The first step is to prepare your environment. This command creates ~/.ssh/sshc.d/ and prepends Include sshc.d/* to your ~/.ssh/config. A backup of your original config is created at ~/.ssh/config.backup.
sshc initsshc supports the following global flags:
--dry-run,-n: Show what would be done without making any changes.
Example:
sshc add config test --host test.com --dry-runAdd a new managed config entry. By default, it uses the name as the host.
sshc add config my-server --host example.com --user adminYou can generate a new SSH key specifically for this configuration:
# Create an Ed25519 key (default)
sshc add config github --host github.com --user git --create-key
# Create a 4096-bit RSA key
sshc add config legacy-server --create-key --key-type rsa --key-size 4096
# Create an Ed25519 key with a comment
sshc add config personal --create-key --key-comment "personal-key"# List all managed configs
sshc list
# Show the content of a specific config
sshc show my-server
# Edit a config in your default editor
sshc edit config my-server
# Update specific fields of a config
sshc edit config my-server --user new-admin --host new-example.com
# Remove a managed config
sshc rm config my-server
# Remove a config and its associated SSH key
sshc rm config my-server --delete-keyHere are some common scenarios where sshc makes managing your SSH configurations easier.
Manage separate keys for your personal and work GitHub accounts without messing up your global config.
# Set up personal GitHub
sshc add config github-personal \
--host github.com-personal \
--hostname github.com \
--user git \
--create-key \
--key-comment "personal@email.com"
# Set up work GitHub
sshc add config github-work \
--host github.com-work \
--hostname github.com \
--user git \
--create-key \
--key-comment "work@company.com"Keep your Dev, Staging, and Production environments organized.
# Development server
sshc add config app-dev \
--hostname dev.example.com \
--user developer
# Staging server
sshc add config app-staging \
--hostname staging.example.com \
--user qa-team
# Production server
sshc add config app-prod \
--hostname prod.example.com \
--user admin \
--forward-agent yesConfigure access to a private server through a secure bastion/jump host.
# 1. Add the bastion host
sshc add config bastion \
--hostname bastion.example.com \
--user jump-user
# 2. Add the internal server using the bastion as a proxy
sshc add config internal-db \
--hostname 10.0.1.50 \
--user db-admin \
--proxy-jump bastionFor older servers that require specific key types or ports.
# Generate a 4096-bit RSA key for a legacy system
sshc add config legacy-box \
--hostname old-server.local \
--port 2222 \
--user sysadmin \
--create-key \
--key-type rsa \
--key-size 4096Easily manage cloud instances with specific identity files.
# Add a cloud instance using an existing downloaded .pem key
sshc add config aws-web \
--hostname ec2-54-xx-xx-xx.compute-1.amazonaws.com \
--user ubuntu \
--identity ~/downloads/aws-prod-key.pemInitializes sshc environment.
- Creates
~/.ssh/sshc.d/directory. - Backs up
~/.ssh/configto~/.ssh/config.backup. - Prepends
Include sshc.d/*to~/.ssh/config.
Adds a new SSH configuration file.
--host string: SSH Host alias (e.g., my-server). Defaults to NAME.--hostname string: The real hostname or IP address (e.g., example.com).--user string: The SSH user.--port int: The SSH port.--identity string: Path to an existing identity file.--forward-agent string: Forward SSH Agent (yesorno).--proxy-jump string: SSH ProxyJump host.--create-key: Generate a new SSH key pair.--key-type string: Key type:ed25519(default),rsa, orecdsa.--key-size int: Key size in bits (for RSA: 2048, 4096; for ECDSA: 256, 384, 521).--key-comment string: SSH key comment (e.g., user@host).
Removes a managed SSH configuration file.
Lists all configuration files managed in ~/.ssh/sshc.d/.
Prints the content of a managed configuration file.
Edits a managed SSH configuration file.
- If no flags are provided, it opens the file in your default editor (
$EDITOR). --host string: Update the SSH Host alias.--hostname string: Update the real hostname/IP.--user string: Update the SSH user.--port int: Update the SSH port.--identity string: Update the path to identity file.--forward-agent string: Update Forward SSH Agent (yesorno).--proxy-jump string: Update SSH ProxyJump.
The project includes a Makefile for common tasks:
make build: Compiles the binary tobin/sshc.make test: Runs the test suite.make lint: Runs the linter.make clean: Removes build artifacts.
MIT
