Creating and Using an SSH Key with GitHub
Generating a New SSH Key
Open a terminal and run the following command to generate a new SSH key with the highest encryption (Ed25519):
shssh-keygen -t ed25519 -C "kelly.carinola@gmail.com"When prompted, specify a file to save the key (press Enter to accept the default location):
shEnter file in which to save the key (/home/your_user/.ssh/id_ed25519):Enter a passphrase for added security (optional but recommended):
shEnter passphrase (empty for no passphrase): Enter same passphrase again:
Adding Your SSH Key to the SSH Agent
Start the SSH agent in the background:
sheval "$(ssh-agent -s)"Add your SSH private key to the SSH agent:
shssh-add ~/.ssh/id_ed25519
Adding Your SSH Key to Your GitHub Account
Copy the SSH key to your clipboard:
shcat ~/.ssh/id_ed25519.pubLog in to your GitHub account and go to the SSH and GPG keys settings:
- Navigate to Settings > SSH and GPG keys > New SSH key
Paste your SSH key into the "Key" field and give it a descriptive title:
- Click Add SSH key
Testing Your SSH Connection
Run the following command to test your SSH connection:
shssh -T git@github.comYou should see a message like this:
shHi username! You've successfully authenticated, but GitHub does not provide shell access.
Generating a New GPG Key
Open a terminal and run the following command to generate a new GPG key:
shgpg --full-generate-keyFollow the prompts to specify the key type, size, and expiration date. Use your GitHub email address:
shReal name: <name> Email address: <your@email.com>Enter a passphrase for added security (optional but recommended):
shEnter passphrase:
Adding Your GPG Key to Your GitHub Account rtql8ive
List your GPG keys and copy the GPG key ID:
shgpg --list-secret-keys --keyid-format LONGExport your GPG key to your clipboard:
shgpg --armor --export YOUR_KEY_ID # Replace YOUR_KEY_ID with the GPG key ID gpg --armor --export BB0C7B1A33F83322Log in to your GitHub account and go to the SSH and GPG keys settings:
- Navigate to Settings > SSH and GPG keys > New GPG key
Paste your GPG key into the "Key" field and give it a descriptive title:
- Click Add GPG key
By following these steps, you can create both SSH and GPG keys with the highest encryption and use them to securely connect to your GitHub account.