简体   繁体   中英

SSH to a server from nodejs with ed25519 key

I tried using the module ssh2 by mscdex which, but it doesn't support the key ed25519.

var Connection = require('ssh2');
var c = new Connection();
c.connect({
    host: host,
    port: port, 
    username: user,
    privateKey: require('fs').readFileSync(keyPath)
});

The error is:

node_modules/ssh2/lib/client.js:225                                               
      throw new Error('Cannot parse privateKey: ' + privKeyInfo.message);                      
      ^                                                                                        

Error: Cannot parse privateKey: Unsupported key format                                         
    at Client.connect

I also tried using node-sshpk because I saw that it supports ed25519, but I didn't find a way to connect to the linux server.

Does anyone know a way to connect to the server using ed25519 keys?

There is an open issue in the ssh2 package.


If you want to use the specific ed25519 format, look at the npm package ed25519 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM