Search code examples
giteclipsegithubssh-keys

How to add an ed25519 ssh key to eclipse for use with github?


I used Git for Windows (v2.30.1) to create an ed25519 ssh key with ssh-keygen -t ed25519 -C “<github email>” per this github doc and added it to my account. I verified it works from Git CMD with ssh -T [email protected].

To load it into eclipse (v2020-12; EGit v5.11), I went here: Preferences --> SSH2 --> Key Management --> Load Existing Key...

When attempting to add the private key, I got this error failed to load given file. EGit v5.4+ "supports" an ed25519 key, but I could find no instructions (expected them here) for how to get one into eclipse. Googling for the error was unhelpful.

How do I use my ed25519 key with eclipse?


Solution

  • It seems odd that you can't use Load Existing Key to, well, load an ssh key. I’m not the only one to make that mistake... Thanks to Howlger for pointing out the relevant doc here. The correct way to add a key is from the General tab by clicking Add Private Key… and selecting your ed25519 private key file (not the one ending in “.pub”).

    I am fairly new at git, so I'm doing as much of it in the eclipse GUI (aka EGit) as possible. I had already cloned a public repo from the Git perspective like so:

    1. Clicked Clone a Git Repository and add the clone to this view --> GitHub
    2. Typed org.aspectj in Search box and clicked Search
    3. Selected eclipse/org.aspectj and clicked Next
    4. Selected the master branch --> Next --> entered local directory
    5. Clicked Finish

    The steps are important because EGit defaulted the repo URI for the remote origin like this: https://github.com/eclipse/org.aspectj. Now that I had my ssh key loaded, I wanted to change that. So, still in the Git perspective, under Remotes I right-clicked origin, clicked Configure push, then Change… and clicked the protocol dropdown, selected ssh and Finish. Back at the Configure push for remote ‘origin’ window, I clicked Save and Push and got this error:

    Can't connect to any repository: ssh://github.com/eclipse/org.aspectj (ssh://github.com/eclipse/org.aspectj: Cannot log in at github.com:22)
    

    Troubleshooting finally led me to this github documentation about the “git” user . I only needed to update origin’s URI to ssh://[email protected]/eclipse/org.aspectj and then it worked like a charm.