[Note #1] How to configure SSH Github
![[Note #1] How to configure SSH Github](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1659279039092%2FfL6XJXQiT.jpg&w=3840&q=75)
In short just follow Generate ssh key and Add the key to Github. This note using Mac in the journey.
Generate SSH key
- Open terminal.
- Use command below to generate ssh key. Use an email that signup with Github.
$ ssh-keygen -t ed25519 -C "your_email@example.com"
- Press enter
> Enter a file in which to save the key (/Users/you/.ssh/id_algorithm): [Press enter]
- Press enter until end or type a passphrase for ssh key (not your Github's password).
> Enter passphrase (empty for no passphrase): [Enter / Type a passphrase]
> Enter same passphrase again: [Enter / Type passphrase again]
If you do until this line you have generated your ssh key for securing your communication with Github or other platform by encrypt/decrypt data using ed25519 algorithm.
Adding SSH key to the ssh-agent
- Start agent process in background.
$ eval "$(ssh-agent -s)"
- Create a ssh config file.
$ touch ~/.ssh/config
- Configure OpenSSH to try using the generated key with every host while automatic add key to ssh agent by edit file
~/.ssh/config.
For using passphrase.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
Without using passphrase.
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519
Add your SSH private key to the ssh-agent.
$ ssh-add -K ~/.ssh/id_ed25519
Adding a new SSH key to Github
- Copy all the contain in
~/.ssh/id_ed25519.pub - Paste the contain in key form by navigate to Github's Profile > Settings > "Access" section > SSH and GPG keys > New SSH key

- Then click "Add SSH key" and confirm with your password.
Configure Github to using SSH even link was https
$ touch ~/.gitconfig
$ open ~/.gitconfig
# Enforce SSH
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
If you want to setup for other site this was an example.
# Enforce SSH
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
insteadOf = https://gitlab.com/
[url "ssh://git@bitbucket.org/"]
insteadOf = https://bitbucket.org/
Reference
Cover Photo by Roman Synkevych πΊπ¦ on Unsplash