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.
- 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.
- Clone the repository or download the script:
git clone https://github.com/yourusername/ghset.git
cd ghset- Make the script executable:
chmod +x ghset.sh- (Optional) Move it to a directory in your
PATHto run it from anywhere:
sudo mv ghset.sh /usr/local/bin/ghsetghsetghset belmo
ghset oppy
ghset personalBefore 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 "[email protected]"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.
- Validates that the SSH keys exist for the selected profile.
- Backs up your current
~/.ssh/configto~/.ssh/config.backup. - Replaces the SSH config with the selected profile's settings.
- Clears old keys from the
ssh-agent. - Adds the selected profile's SSH key to the agent.
- Tests the connection to GitHub.
$ 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.MIT