invalid priatekey error

Answered

I'm trying to add a SSH Interpreter in my project. I tried to use key pair to connet to the remote server. However, it show me "Failed to load identity file".

Then I go to "Tools/Deployment/Configuration" and try to add the server. I choose "Key pair (OpenSSH or PuTTY)" as the Auth type, and select id_rsa in my .ssh folder as the Private key file. And It shows "Keypair '/home/xxx/.ssh/id_rsa' is corrupt or has unknown format. Only SSH2 keys in OpenSSH format (DSA, RSA or ECDSA) or PuTTY private key *.ppk keys are supported. Error message: invalid privatekey: [B@663f5538"

I generate my ssh key by "ssh-keygen -t rsa -C XXX" command.

What shold I do?

6
14 comments

Hi,

Please try generating using this command: http://unix.stackexchange.com/a/30074 . Or converting to ssh2 format: http://unix.stackexchange.com/a/84122

If doesn't work, please create a ticket in our bug tracker (https://youtrack.jetbrains.com/issues/PY) and attach a screenshot showing the problem and idea.log from Help | Show Log in ... .

2
Avatar
Permanently deleted user

Hey, I have the same issue. My ssh used to work and then all of the sudden it stopped working. Did you guys now require ssh2 format? Was a ticket created for this?

edit: isn't ssh2 for windows. Also the link that you provided state that we cannot convert the private rsa key to ssh2

1

Hi,

Does it look similar to https://youtrack.jetbrains.com/issue/PY-24325?
If not, please submit another issue, attach a screenshot showing the problem and idea.log from Help | Show Log in ...

0
Avatar
Permanently deleted user

Hi Sergey,

It's similar. It is surprising because it just happened all of sudden for no reason. My RSA key use to work. Also, I have pycharm on my work mac laptop and home mac laptop. I have the same versions of PyCharm on both machines. I imported the same settings. I used the same RSA file for both. It works fine on my work laptop but not on my home laptop. So, one mac, PyCharm has no issue with the RSA key and, on the other, it says that it is corrupt. I copied the RSA keys from my work laptop and it still does not work.

I submitted a ticket yesterday: https://youtrack.jetbrains.com/issue/PY-32937

Thanks

3
Avatar
Permanently deleted user

Hi Sergey,

So I managed to make it work on my home mac. When I my computer and tried to ssh into my server, I got `Permissions 0644 for '/Users/jonat/.ssh/id_rsa' are too open.` so I `chmod 400 ~/.ssh/id_rsa`. I restarted my computer again. I got the same message. So I opened the terminal inside the IDE and did  `ssh-add ~/.ssh/id_rsa &>/dev/null`. Voila! It worked after that.

Thanks

3
Avatar
Permanently deleted user

Hey, I have the same issue.

I just do it successfully.

 

I used XShell to manage my ssh.

open your ssh properties.

 

select your user key, then Export ...


select your pc path to save and type is 'PEM (OpenSSH2) Private Keys'

 

 

 



 

0
Avatar
Permanently deleted user

I've figured out what is causing this.  OpenSSH version 7.9p1, released on 10/19/2018, generates keys that trigger this alert message and prevent key pair configuration.  https://www.openssh.com/releasenotes.html.  I tried generating keys with the previous version of OpenSSH and keys with version 7.9p1 and verified the issue.  A quick fix would be regenerating your keys with an older version of OpenSSH.  I would really like to know what about this new version is causing this bug but do not really know much about this stuff at the moment.  

1
Avatar
Permanently deleted user

Generate your rsa keys like this to fix the issue: 

ssh-keygen -m PEM -C "email"

3
Avatar
Permanently deleted user

The solution from Jonathan Pilault worked - thanks!

In my case, I had to create a new keypair and add a passphrase; my id_rsa did not have a passphrase. This also allowed my MySQL client to connect.

Also on OpenSSH version 7.9p1.

1

Encountered this error after setting up a new machine.

This fix sorted it out. https://youtrack.jetbrains.com/issue/PY-24325#focus=streamItem-27-3169574-0-0

Hopes this helps someone. 

0
Avatar
Permanently deleted user

ssh-keygen -m PEM -C "email"

Above command perfectly works when i tried to connect to AWS GLUE dev point
0
Avatar
Permanently deleted user

Invalid

```
-----BEGIN OPENSSH PRIVATE KEY-----
```


Correct

```
-----BEGIN RSA PRIVATE KEY-----
```

 

Step to fix

Remove old files

```
rm -rf ~/.ssh/*
```

Create new File (-m pem)

```
ssh-keygen -t rsa -b 2048 -m pem -f ~/.ssh/google_compute_engine -C username
```

 

 

 

0
Avatar
Permanently deleted user

The workaround in the thread posted by @Andrey Resler worked. Just converted my existing private key (test_id_rsa) into the format expected by PyCharm using PuTTY's puttygen tool:

$puttygen id_rsa -O private-openssh -o test_id_rsa.puttygen

Did not need my passcode after the conversion above.

0

Please sign in to leave a comment.