setup ed25519 ssh key for github

1. check for existing ssh keys

Run:

ls -al ~/.ssh

Look for id_ed25519 or similar files.

2. generate a new ssh key

Run:

ssh-keygen -t ed25519 -C "[email protected]"

Press Enter to accept the default location (~/.ssh/id_ed25519) and optionally set a passphrase.

3. add the key to ssh agent

Start the SSH agent:

eval "$(ssh-agent -s)"

Then add your private key:

ssh-add ~/.ssh/id_ed25519

4. copy the ssh public key

Run:

cat ~/.ssh/id_ed25519.pub

Or use:

pbcopy < ~/.ssh/id_ed25519.pub    
xclip -sel clip < ~/.ssh/id_ed25519.pub    

5. add ssh key to github

  1. Go to GitHub > Settings > SSH and GPG keys.
  2. Click New SSH key.
  3. Paste your public key into the "Key" field and click Add SSH key.

6. test the ssh connection

Run:

ssh -T [email protected]

You should see a success message.

optional: git config

Set Git to use SSH:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Clone a repo using SSH:

git clone [email protected]:username/repository.git

additional: ssh config

In ~/.ssh/config (if needed):

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519
Return to Home