Available languages:
This Bash script simplifies SSH key management for a user. It allows checking for existing SSH keys, displaying the current public key, and generating a new ED25519 SSH key with a provided email.
⚠️ Note: This script is intended for Linux systems only. A Windows-compatible version (likely using PowerShell) is planned for a future update.
- Check if an SSH key already exists (
id_ed25519.pub) - Show the current SSH public key
- Generate a new SSH key pair with a given email address
- Optionally install
ssh-keygenif it's not present - Automatically adds the key to
ssh-agentif it's running
Clone this repository to your local machine running the following commands:
git clone https://github.com/sfonzo96/ssh-keys-gh
cd ssh-keys-gh./set_ssh_key.sh [option] [email]-
-h,--helpShow usage information. -
-s,--showDisplay the current SSH public key. -
-c,--checkCheck if an SSH key already exists. -
-g,--generate <email>Generate a new SSH key pair. Requires a valid email as an argument.
Check if an SSH key exists:
./set_ssh_key.sh --checkGenerate a new key with an email:
./set_ssh_key.sh --generate your_email@example.comShow your current SSH public key:
./set_ssh_key.sh --show-
After generating the SSH key, you need to add it to your GitHub account. Follow these steps:
- Copy the SSH key to your clipboard:
- Go to your GitHub account settings.
- Navigate to "SSH and GPG keys".
- Click on "New SSH key".
- Add a title for the key (e.g., "My Laptop SSH Key").
- Make sure the "Key type" field has the "Authentication Key" option selected.
- Paste the SSH key into the "Key" field.
- Click "Add SSH key".
- You may be prompted to enter your GitHub password to confirm the addition of the key.
-
Following those steps should allow you to push and pull from your GitHub repositories right away.
- If
ssh-keygenis not installed, the script will prompt to install it usingapt-get. - Keys are generated using the ED25519 algorithm and stored at
~/.ssh/id_ed25519.
- Add support for Windows via PowerShell
- Implement more advanced error handling