Skip to content

Latest commit

 

History

History
102 lines (70 loc) · 2.14 KB

File metadata and controls

102 lines (70 loc) · 2.14 KB

ghset - SSH Profile Switcher for GitHub and Bitbucket

This script allows you to quickly switch between different SSH profiles for GitHub and Bitbucket, making it easy to manage multiple accounts (personal, work, etc.) on the same machine.


📦 Available Profiles

  • belmo → Example profile (requires your SSH key path)
  • oppy → Example profile (requires your SSH key path)
  • personal → Example profile (requires your SSH key path)

You can rename or edit these profiles inside the script to match your own setup.


🚀 Installation

  1. Clone the repository or download the script:
git clone https://github.com/yourusername/ghset.git
cd ghset
  1. Make the script executable:
chmod +x ghset.sh
  1. (Optional) Move it to a directory in your PATH to run it from anywhere:
sudo mv ghset.sh /usr/local/bin/ghset

🛠 Usage

Show current profile and help

ghset

Switch to a specific profile

ghset belmo
ghset oppy
ghset personal

🔑 SSH Keys Setup

Before using the script, you must create your own SSH keys and add their paths in the script for each profile.

Example for creating a new SSH key:

ssh-keygen -t ed25519 -C "your_email@example.com"

Then update the script with the correct paths to your private keys, for example:

~/.ssh/id_belmo
~/.ssh/id_oppy
~/.ssh/id_personal

Make sure the corresponding public keys (.pub files) are also present.


🔍 What the script does

  1. Validates that the SSH keys exist for the selected profile.
  2. Backs up your current ~/.ssh/config to ~/.ssh/config.backup.
  3. Replaces the SSH config with the selected profile's settings.
  4. Clears old keys from the ssh-agent.
  5. Adds the selected profile's SSH key to the agent.
  6. Tests the connection to GitHub.

📌 Example Output

$ ghset oppy
Backup created: /Users/youruser/.ssh/config.backup
Profile switched to: oppy
SSH Key: ~/.ssh/id_oppy

Testing connection...
Hi youruser! You've successfully authenticated, but GitHub does not provide shell access.

📜 License

MIT