I ran into .ssh authentication problem for my GitHub repo with MacBook Pro M1.
Originally I followed the steps from GitHub and started the authentication with the
“ssh-keygen -t ed25519 -C firstname.lastname@example.org" command which generated id_ed25519 file in the /.ssh folder.
The authentication of the SSH key kept failing and ran into the following error message:
“cannot add ed25519-sk ssh key”.
The issue was resolved via the following steps:
I installed Xcode which ships with the latest version of Git. Of course, there are other installation options for Git, which you can choose from
After you install Git on the system run the following commands from the Terminal:
The “ssh-keygen” command generated the “id_rsa” files instead of the “id_ed25519”.
The “ssh-keygen” command generates the file path. Copy the file path and add your custom name to the rsa file if you wish, so it’s easier to identify it later. You can also just hit enter and the rsa files will be generated.
Hit enter and type in your password (twice). Hit enter and the system generates both public and private rsa files.
You can open the /.ssh folder via finder or via the command line. In the finder to show the hidden system files use shift+⌘+.
Open and update the .ssh/config file with the following information for authentication for GitHub:
Saved and closed the /.ssh/config file.
Run the ssh-agent in the background with one of the following commands, depending on your environment. This should output an agent pid number.
eval $(ssh-agent -s) or exec ssh-agent zsh
From the terminal run “ssh-add” command to avoid entering the password all the time:
ssh-add --apple-use-keychain ~/.ssh/id_rsa_yourcustomnameforgithub
Hit enter and type in the password again.
Now copy the public ssh key generated:
pbcopy < ~/.ssh/id_rsa_yourcustomnameforgithub.pub (make sure to copy the public key)
Log into GitHub under Settings > SSH and GPG keys. Name your new ssh key and paste your ssh key via ⌘ + v
Save your SSH key and test your connection via cloning an actual repo.