Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse privateKey: Unsupported key format #1032

Closed
Twisterking opened this issue Nov 21, 2018 · 12 comments
Closed

Cannot parse privateKey: Unsupported key format #1032

Twisterking opened this issue Nov 21, 2018 · 12 comments

Comments

@Twisterking
Copy link
Contributor

Mup version (mup --version): 1.4.5

Okay so the problem is, that macOS Mojave is creating new OpenSSH keys, which can't be parsed with the ssh2 module. I googled a lot but I can't get it to work. :(

The older keys started with

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

the newer ones with

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

Anyone found a way to fix this?

Output of command

Error: Cannot parse privateKey: Unsupported key format
    at Client.connect (/usr/local/lib/node_modules/mup/node_modules/nodemiral/node_modules/ssh2/lib/client.js:156:13)
    at SSH.connect (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/ssh.js:12:16)
    at Session._withSshClient (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/session.js:58:12)
    at Session.copy (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/session.js:94:10)
    at doCopy (/usr/local/lib/node_modules/mup/lib/nodemiral.js:22:13)
    at Object.copy (/usr/local/lib/node_modules/mup/lib/nodemiral.js:50:3)
    at runTask (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/taskList.js:98:43)
    at TaskList._runTaskQueue (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/taskList.js:89:3)
    at iterator (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/taskList.js:55:10)
    at /usr/local/lib/node_modules/mup/node_modules/nodemiral/node_modules/async/lib/async.js:249:17
    at iterate (/usr/local/lib/node_modules/mup/node_modules/nodemiral/node_modules/async/lib/async.js:149:13)
    at async.eachSeries (/usr/local/lib/node_modules/mup/node_modules/nodemiral/node_modules/async/lib/async.js:165:9)
    at _asyncMap (/usr/local/lib/node_modules/mup/node_modules/nodemiral/node_modules/async/lib/async.js:248:13)
    at Object.mapSeries (/usr/local/lib/node_modules/mup/node_modules/nodemiral/node_modules/async/lib/async.js:231:23)
    at TaskList.run (/usr/local/lib/node_modules/mup/node_modules/nodemiral/lib/taskList.js:49:11)
    at /usr/local/lib/node_modules/mup/lib/utils.js:88:10
@Twisterking
Copy link
Contributor Author

No one had this problem? No new mac users here? I there any trick I couldn't find to generate a key with the old syntax? What I did in the end to circumvent this is create a new ssh key on an old machine and copy it to my new mac. But this is not really a nice way to do it.

@chdagenais
Copy link

@Twisterking
See here
Try to generate your key pair with ssh-keygen -m PEM -t rsa

@jankapunkt
Copy link

I have the same error on MacOS but I think it is because I have to generate my keys using ssh-ed25519 which may not be supported, yet?

@Twisterking
Copy link
Contributor Author

@charlesdagenais If I remember correctly I tried that and it still didn't work, still had some new syntax which couldn't be parsed.

@jankapunkt So what was the exact command you used? Does it work now or are you still getting that error?

@jankapunkt
Copy link

jankapunkt commented Jan 9, 2019

@Twisterking mey key is generated using ed25519 algorithm, which is not supported by the ssh2 module. My cloud provider however requires me to auth via ssh using keys generated using ed25519.

A username/password combination is denied by the server as I can only login using the key via ssh -i user@server. Is there any workaround for this?

@isoceles
Copy link

isoceles commented Jan 11, 2019

I had the same issue on Mojave but got it working after many hours of trying different things. Here's what worked for me:

  1. Delete your droplet
  2. Create a new key ssh-keygen -m PEM -t rsa -b 2048 -C "<your_email_address>" (no pass phrase)
  3. Copy the public key cat ~/.ssh/id_rsa.pub
  4. Digital Ocean > Account > Security > Add the copied SSH Key
  5. Create a new droplet and select the name of the SSH key you just created.
  6. (optional) SSH into your droplet to test ssh root@<ip_address>
    • it will say "The authenticity of host 'IPaddress' can't be established." write yes
      • if access is denied I'm not sure what to do but you can remove the cached key by typing ssh-keygen -R <ip_address>
      • if you get access exit SSH Ctrl + d continue to next step.
  7. mup setup

I hope this helps. Good luck!

@jmendiola222
Copy link

jmendiola222 commented May 30, 2019

Seems like ssh2 module has add support

Full Ed25519 support now available in ssh2 v0.8.3 when used with node v12.0.0.

mscdex/ssh2#352 (comment)
Any plan to update to this new version?

@jankapunkt
Copy link

Awesome, however

when used with node v12.0.0

seems to me that it will take a while until Meteor will be at v12

@kevin-foster-uk
Copy link

You can change the type of private key without needing to modify your public key:

ssh-keygen -m PEM -p -f ~/.ssh/id_rsa

@zodern
Copy link
Owner

zodern commented Jul 14, 2019

The latest beta of 1.5 should support the additional formats.

@zodern zodern closed this as completed Jul 14, 2019
@pachkovska
Copy link

thank you, generating additional private key solved my problem as well.

@divya14mishra
Copy link

I have the same error working in node.js(node-ssh) windows 11 and 10,
I tried using ssh-keygen -m PEM -p -f ~/.ssh/id_rsa,
nothing worked, any help would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants