Skip to content

A cli tool to manage multiple ssh keys and switch between different ssh keys with ease & grace.

Notifications You must be signed in to change notification settings

shahidullahkhankhattak/ssh-keyman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ssh-keyman

Build Status Tests Test Coverage Tests Passing

npm version npm downloads Node Version

License: ISC Maintained PRs Welcome

Last Commit Issues Pull Requests Stars

A sophisticated key manager cli tool to manage multiple ssh keys and switch between different ssh keys with ease & grace.

CI/CD Status

Workflow Status
Build & Test CI
Test Coverage Coverage
NPM Publish Publish

πŸ“Š View Detailed Status Report β†’

Platform Support

Tests run automatically on:

  • βœ… Ubuntu (Linux) - Node.js 16.x, 18.x, 20.x
  • βœ… macOS - Node.js 16.x, 18.x, 20.x
  • βœ… Windows - Node.js 16.x, 18.x, 20.x

35 Tests | 75%+ Coverage | All Platforms Passing

Overview


Normally people have difficulty managing different ssh keys for different Github / Bitbucket / Gitlab accounts. This package makes your life easier by creating different ssh profiles & manage them for you. So you can concentrate on your work.

Installation

npm install -g ssh-keyman

Usage

➜  ~  ssh-keyman -h

SSH KeyMan - SSH Key Environment Manager

Usage: ssh-keyman <command> [options]

Commands:
  -i           Initialize keyman directory and default environment
  -c [name]    Create new ssh environment (interactive if no name)
  -s [name]    Switch to another ssh environment (interactive if no name)
  -d [name]    Delete ssh environment (interactive if no name)
  -ls          List all environments
  -h           Show help
  -v           Show version

Tip: Run commands without arguments for interactive mode

✨ New Interactive Features

ssh-keyman now supports interactive mode with autocomplete! Simply run commands without arguments to get an enhanced interactive experience:

  • ssh-keyman -s - Interactive environment switcher with autocomplete
  • ssh-keyman -c - Interactive environment creator with validation
  • ssh-keyman -d - Interactive environment deletion with confirmation

Initialisation

Calling ssh-keyman -i creates a ~/.sshkeyman/ directory if it doesn't exist, and copies your current ~/.ssh as the 'default' ssh profile.

➜  ~  ssh-keyman -i

πŸ”‘ Initializing SSH KeyMan...

βœ“ Created ssh-keyman directory: /Users/shahidullahkhan/.sshkeyman
βœ“ Created default environment
βœ“ Activated 'default' environment

✨ SSH KeyMan initialized successfully!

Create a new ssh environment

With environment name:

➜  ~  ssh-keyman -c newenvironment
βœ“ Saved current ssh config to default
βœ“ Created directory for new environment: /Users/shahidullahkhan/.sshkeyman/newenvironment
? Do you want to switch to newly created environment (newenvironment)? (Y/n) y
βœ“ Activated environment 'newenvironment'

Interactive mode (just run without name):

➜  ~  ssh-keyman -c
? Enter name for the new environment: production
βœ“ Saved current ssh config to default
βœ“ Created directory for new environment: /Users/shahidullahkhan/.sshkeyman/production
? Do you want to switch to newly created environment (production)? (Y/n) 

A blank environment will be created. Then modify content of ~/.ssh/. Then whenever you will switch to another environment, your changes will be saved.

List available ssh environments

➜  ~  ssh-keyman -ls

Available environments:
  β€’ default
  βœ“ newenvironment (active)

Switch to a specific ssh environment

With environment name:

➜  ~  ssh-keyman -s default
βœ“ Saved current ssh config to 'newenvironment'
βœ“ Activated environment 'default'

Interactive mode with autocomplete (just run without name):

➜  ~  ssh-keyman -s
? Select environment to switch to: (Use arrow keys or type to search)
❯ default
  production
  staging

Start typing to filter environments with autocomplete!

Delete a specific ssh environment

With environment name:

➜  ~  ssh-keyman -d newenvironment
βœ“ Successfully deleted environment 'newenvironment'

Interactive mode with autocomplete and confirmation (just run without name):

➜  ~  ssh-keyman -d
? Select environment to delete: (Use arrow keys or type to search)
❯ newenvironment
  staging
? Are you sure you want to delete environment 'newenvironment'? (y/N) y
βœ“ Successfully deleted environment 'newenvironment'

Get the current ssh-keyman version

➜  ~  ssh-keyman -v
ssh-keyman version 1.0.2

Development

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:ci

Project Structure

ssh-keyman/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __tests__/          # Test files
β”‚   β”œβ”€β”€ cli.js              # CLI entry point
β”‚   β”œβ”€β”€ cliOptions.js       # CLI argument parsing
β”‚   β”œβ”€β”€ commands.js         # Command implementations
β”‚   β”œβ”€β”€ constants.js        # Constants and configuration
β”‚   └── extendFs.js         # File system utilities
β”œβ”€β”€ .github/
β”‚   └── workflows/          # GitHub Actions CI/CD
β”œβ”€β”€ index.js                # Main entry point
└── package.json

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

ISC, a permissive free software license published by the Internet Software Consortium.

Contact

Made with ❀️ by Shahid Ullah Khan from Pakistan.

About

A cli tool to manage multiple ssh keys and switch between different ssh keys with ease & grace.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors