The process is the same for both Windows and Mac. On Windows, you can use the powershell terminal and on Mac, the standard terminal will work.
- Open the terminal ,Enter the following:
1 **ssh-keygen -t ed25519 -C "email@example.com"**
- Replace the email with your own and press enter.
- It will prompt to enter a password. Hit enter to skip setting a password and do the same for entering the same passphrase again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Generating public/private ed25519 key pair. Enter file in which to save the key (C:\Users\harsh/.ssh/id_ed25519): Created directory 'C:\\Users\\harsh/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\harsh/.ssh/id_ed25519 Your public key has been saved in C:\Users\harsh/.ssh/id_ed25519.pub The key fingerprint is: SHA256:4Z4OiYAa0OV54doT+eDXAsVvkLiTvLYIFxZdNlHjRCQ firstname.lastname@example.org The key's randomart image is: +--[ED25519 256]--+ | ...+E** | | . o.oo=+= . | |. . ooBo.o. | |.. o==* oo | |o ....+oS.. | |......o= o | |. o.oo.o | | . .o | | . | +----[SHA256]-----+
- Once you have confirmed it will generate the above to confirm the keys have been created.
- Both keys will be stored in the .ssh folder.
- In order to add our key to Github, we need to get a copy of the public key which is always identified as .pub in your local directory.
1 PS C:\Users\harsh> pbcopy < C:\Users\harsh/.ssh/id_ed25519.pub
- This will display the key on your terminal and also copy the content of the file in clipboard
We now need to add our public key to Github to grant access to the repositories we create.
Step 1: Log on to Github
Step 2: Click on the profile icon in the top right of the screen and select Settings.
- Click the New SSH key button in Green on the right-hand side of the screen.
- Enter a title and paste in your public key that you copied previously.
- Click the Add SSH key button.
You are now ready to access Github via SSH.