When using several ssh keys on your Mac, you need to give them distinct names, and in therefore you may encounter a problem: The system may not use the key, because it does look for the standard names only*. Happened to me, when I set up a ed25519 key for my university Gitlab account. Even after adding the ssh key to Gitlab, it would keep asking me for the password, when I tried to connect with
ssh -T email@example.com
*) You can watch this behavior by typing
ssh -vvv firstname.lastname@example.org into your terminal.
Solution: Just make the system aware of your key by
ssh-add -K ~/.ssh/my_special_keyname
Starting from macOS Monterey (12.0), the
-K flag is deprecated and has been replaced by the
I found on a new machine with macOS Ventura, I had to add the above line also to my .zshrc file, otherwise it would be gone after a reboot.
Just to have it all in one place
Create key pair:
ssh-keygen -t ed25519 -C "Comment"
Copy public key (macOS):
pbcopy < yourkey.pub