How to setup SSH key for Git from scratch
Published:
Writing this blog, as I always have to look up for various links on the internet to set up Git and SSH keys on a fresh install of an operating system. The following setup is for Linux
- Install
git
. Run
sudo apt install git-all
- Check the version to see if installed correctly
git --version
- Setup the configuration file by adding your name and email address
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
- Create a new SSH key
ssh-keygen -t ed25519 -C "johndoe@example.com"
Press enter to select the default location - Start the SSH agent in background
eval "$(ssh-agent -s)"
- Now, add the SSH private key to the SSH agent
ssh-add ~/.ssh/id_ed25519
- Copy the SSH public key
cat ~/.ssh/id_ed25519.pub
- Add this key to your GitHub account by navigating to the SSH key section in settings
References: