I wanted to generate an SSH key for my GitHub account. Following this guide, I ran ssh-keygen -t ed25519 -C "my@email.com"
. I gave it the filename github_main
and put in a passphrase. All that worked fine.
Running ssh-add ~/.ssh/github_main
gave a problem, but I resolved that by running the command with a slightly different path. It returned Identity added: C:/Users/brent/.ssh/github_main (my@email.com)
, so I assumed everything worked.
I then tested the connection with ssh -T git@github.com
. It said I was successfully connected, but GitHub doesn't provide shell access, which looked to me like it worked.
I added the SSH token to my GitHub account, no problems there either. Then, I tried cloning one of my repositories through SSH, which strangely didn't work; it gave the following result:
Cloning into 'my-repo'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I tried cloning the same repository with the HTTPS and that worked fine. After about an hour of googling and searching, I had read multiple times that the file name has no influence on the result, yet I decided to try renaming the files to the original names. I renamed the public key to id_ed25519.pub
and the private key to id_ed25519
. This time, when I tried cloning the repository with the SSH, it asked for the passphrase and cloned the repository. This confuses me a lot, especially since everything I've read so far has told me that the file name does not matter.
Although it works with having the files named id_ed25519
, I'd still like to rename the files since this file name tells me nothing about the key, and that I can only have one key encrypted like this.