archimatetool / archi-modelrepository-plugin

coArchi - a plug-in to share and collaborate on Archi models.
153 stars 52 forks source link

Invalid private key while using SSH #88

Closed BabetteW closed 2 years ago

BabetteW commented 5 years ago

I configured SSH authentication for github via the preference menu as described on the Wiki.However when I try to import a remote model I get an error that the private key is invalid.

If I clone the model via the command line it works just fine. So the public private key combination is correct.

There is no error in the logfile (accessable via about archi menu) that provides more detail. Is there a way I can get more details on the error so that I can correct the issue or provide you with a more detailed error description.

Phillipus commented 5 years ago

If you are using SSH from the command line and it works, it should also work in the UI. Can you double check your settings?

Phillipus commented 5 years ago

Are you seeing an error dialog like:

There was an error: <url> invalid privatekey: []

I could get that error if I set my key file to id_rsa.pub rather than id_rsa

avina-z commented 5 years ago

I having the same error as well. I am using the plugin on a Mac with OS Mojave 10.14.3. I can use my key and passphrase on other applications that connect to the repositories, but the plugin keeps telling me "invalid privatekey"

Phillipus commented 5 years ago

I have to say that I'm not an SSH expert here and this is quite a new feature so would appreciate help from others.

From my limited experience, things to check are that it is actually the id_rsa file that is set in preferences and that this file is in the PEM format as per the wiki - https://github.com/archimatetool/archi-modelrepository-plugin/wiki/SSH-Authentication

Phillipus commented 5 years ago

@potto007 Could you help out with this issue?

Ridderby commented 5 years ago

Hi,

I had the same issue. To explore the problem I went to properties to verify the key-file path and tried to select a new keyfile with the exact same path and then it worked like a charm. Possibly there is a problem with the default-value is not forwarded correctly or something. Visually it seems right but clearly is not.

Well, this worked as a workaround for me.

BR Erik

Phillipus commented 5 years ago

I tried this with a new setup on a Mac.

  1. I copied over my existing id_rsa.pub and id_rsa files that I had created on my Windows machine into ~/.ssh
  2. In Archi's Prefs set my Identity password for the key file id_rsa

All seemed OK.

@Ridderby can you reproduce this more than once?

If there is a problem finding the id_rsa file there would be a different message. Because it says "invalid private key" there must be something else going on.

Phillipus commented 5 years ago

We need more details to find the common factor here.

Operating System - Mac, Windows?

Double check path to key file is correct, and not referencing the public key file.

avina-z commented 5 years ago

After several tests I manage connect to my repository. I was using a key file named id_rsa_archi since I did not want to disturb my original id_rsa file. Despite of given the full path and filename in the Identity file parameter, it was nor working. After I renamed my new key file to id_rsa, the plugin was able to connect.

Phillipus commented 5 years ago

@avina-z I checked this and it seems to be working OK.

Can you rename it back to id_rsa_archi and set the Preference again, making sure you press "Apply and Close" in the dialog. And double check that the preference has remembered the new file path.

Phillipus commented 5 years ago

Are people using different repository providers with different SSH key files? It's possible to create one key file for GitHub and one for BitBucket. Perhaps this is the cause?

jakros commented 5 years ago

Hi all, I experienced exactly same problem and after digging for I while, I found both the cause and solution. Cause: new openssh libs used to generate keys by default save private keys in a different file format that jgit package used in Archi can't handle. New file format starts with "-----BEGIN OPENSSH PRIVATE KEY-----", while the old one has a different header "-----BEGIN RSA PRIVATE KEY-----" Solution: (copy) convert your private key file ssh-keygen -p -f file -m pem -P passphrase -N passphrase (if the key is not encrypted with a passphrase, use "" instead of passphrase) more on that: https://stackoverflow.com/questions/53134212/invalid-privatekey-when-using-jsch

Phillipus commented 5 years ago

The PEM format is required, certainly.

From the comment above:

...things to check are that it is actually the id_rsa file that is set in preferences and that this file is in the PEM format as per the wiki - https://github.com/archimatetool/archi-modelrepository-plugin/wiki/SSH-Authentication

120technology commented 4 years ago

I've had the same problem as others here when using a PEM key.

I found today that on Mac and Linux, I can name the key whatever I want. But from Windows the keypair only works if, like @avina-z found, I name my keypair as id_rsa. Other name (id_rsa2, id_rsa_pem, pemkey) did not work.

Hope that helps somehow.

WoozyMasta commented 4 years ago

What about id_ed25519? It does not work, but it is an internal standard and there is no possibility to use RSA.