sanketbajoria / ssh2-promise

ssh with promise/async await and typescript support
https://www.npmjs.com/package/ssh2-promise
MIT License
148 stars 24 forks source link

Cannot parse privateKey: Unsupported key format #26

Closed takase1121 closed 5 years ago

takase1121 commented 5 years ago

I tried to log in to my ssh server but it failed with this error. The key works, I tested it with openssh and it connects properly and its also in openssh format.

sanketbajoria commented 5 years ago

@takase1121 It does support openssh PEM format key. Can you please provide the configuration, which you are using

takase1121 commented 5 years ago
const client = new ssh({
    host: '192.168.0.12',
    username: 'webmin-tunnel',
    identity: 'webminkey',
    debug: (str) => console.log(str),
    compress: true
})

This is what i used, whereas webminkey is the key file

walkerford commented 5 years ago

I had the same problem with a stock key created with ssh-keygen. This package currently depends on an older version of ssh2 (0.6.2). The latest version of ssh2 (0.8.2) seems to handle private keys better. I updated the packages.json file and then used npm to download the updated ssh2. Now the key works fine. The package maintain should update ssh2 to the latest.

sanketbajoria commented 5 years ago

@wtford , @takase1121 Updated to latest ssh2 package https://github.com/sanketbajoria/ssh2-promise/commit/240b3138e5d5663d7c66a4385e1c8bb01087483b

sanketbajoria commented 5 years ago

@takase1121, @wtford Please, verify, if you still face the issue of parsing privatekey

takase1121 commented 5 years ago

At least now it spits another error saying that ed25519 is not supported. I assume that this bug is fixed.

sanketbajoria commented 5 years ago

@takase1121 Seems like new version 0.8.3 ssh2 has been released. Will be bumping ssh2-promise again

walkerford commented 5 years ago

I updated ssh2-promise to latest and my project parses privatekey without issue. Thanks for keeping this project updated.

sanketbajoria commented 5 years ago

@takase1121 new version of ssh2-promise has been released. Now it should support ed25519

sanketbajoria commented 5 years ago

Closing this issue, as comment further. Please feel free to open it again. If you face any problem

andydix commented 5 years ago

I still can't get an ed25519 key to work. I get the following error...

{ "errorType": "Error", "errorMessage": "Cannot parse privateKey: Unsupported OpenSSH private key type: ssh-ed25519", "trace": [ "Error: Cannot parse privateKey: Unsupported OpenSSH private key type: ssh-ed25519", " at Client.connect (/opt/nodejs/node_modules/ssh2/lib/client.js:243:13)", " at __$connectPromise.Promise (/opt/nodejs/node_modules/ssh2-promise/dist/sshConnection.js:246:16)", " at new Promise ()", " at SSHConnection.connect (/opt/nodejs/node_modules/ssh2-promise/dist/sshConnection.js:181:34)", " at SSH2Promise.getSSHConnection (/opt/nodejs/node_modules/ssh2-promise/dist/index.js:132:20)", " at /opt/nodejs/node_modules/ssh2-promise/dist/index.js:146:36", " at SSH2Promise.connect (/opt/nodejs/node_modules/ssh2-promise/dist/index.js:156:15)", " at SSH2Promise. (/opt/nodejs/node_modules/ssh2-promise/dist/index.js:95:29)", " at $ready.then (/opt/nodejs/node_modules/ssh2-promise/dist/sftp.js:31:45)", " at process._tickCallback (internal/process/next_tick.js:68:7)" ] }

Has anyone managed to get a connection using an ed25519 key pair?