Back to Blog

How to Create an SSH Key

December 25, 2025·2 min read

Quick idea

You’ll generate an SSH keypair, upload the public key to the service you use (GitHub/Bitbucket/etc.), and optionally configure SSH so you can use multiple keys cleanly.

Recommended key type: Ed25519.


1) Create an SSH key

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

By default, this creates:

  • ~/.ssh/id_ed25519 (private key)
  • ~/.ssh/id_ed25519.pub (public key)

Tip: If you want a custom filename (useful when you’ll have multiple keys):

ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/id_ed25519_custom

2) Add your key to ssh-agent (so you don’t type the passphrase every time)

Start the agent:

eval "$(ssh-agent -s)"

Add your key:

ssh-add ~/.ssh/id_ed25519

If you used a custom filename, add that instead:

ssh-add ~/.ssh/id_ed25519_custom

3) Copy your public key and add it to GitHub / Bitbucket / others

Print your public key:

cat ~/.ssh/id_ed25519.pub

If you used a custom filename:

cat ~/.ssh/id_ed25519_custom.pub

Then paste it into your provider’s SSH key settings.

4) Test your SSH connection

GitHub:

ssh -T git@github.com

Bitbucket:

ssh -T git@bitbucket.org

Note: You can use multiple SSH keys (GitHub + Bitbucket, or multiple accounts)

If you need multiple keys, generate them with different filenames, then configure ~/.ssh/config to pick the right key per host.

Example: ~/.ssh/config:

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_github
  IdentitiesOnly yes

Host bitbucket.org
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/id_ed25519_bitbucket
  IdentitiesOnly yes

“Create a key with a specific public key” (what’s actually possible) You cannot generate a new private key that matches an arbitrary public key. A public key only works if you also have the matching private key.

Use an existing keypair (import your private key)

  1. Put the private key file in ~/.ssh/
  2. Fix permissions:
chmod 600 ~/.ssh/id_ed25519_custom
  1. Re-generate the public key from the private key:
ssh-keygen -y -f ~/.ssh/id_ed25519_custom > ~/.ssh/id_ed25519_custom.pub
  1. Upload that .pub to GitHub/Bitbucket.

Written by Kenneth Solomon

Laravel and API integrations engineer, based in the Philippines. Available for contract, overflow and full-time work.

Follow Me

Let's work together.

Let’s collaborate to build innovative, user-focused web applications that help your business thrive!

Quote of the Day 🧠

""

-

© 2026 Kenneth Solomon