sshpk
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
asn1 | 0.2.6 | 5.84 kB | MIT | prod | |
assert-plus | 1.0.0 | 3.85 kB | MIT | prod | |
bcrypt-pbkdf | 1.0.2 | 10.85 kB | BSD-3-Clause | prod | |
dashdash | 1.14.1 | 22.99 kB | MIT | prod | |
ecc-jsbn | 0.1.2 | 7.91 kB | MIT | prod | |
getpass | 0.1.7 | 2.54 kB | MIT | prod | |
jsbn | 0.1.1 | 13.39 kB | MIT | prod | |
safer-buffer | 2.1.2 | 11.75 kB | MIT | prod | |
tweetnacl | 0.14.5 | 48.5 kB | Unlicense | prod |
SSHpk is an npm package that provides functionality to parse, convert, fingerprint, and utilize SSH keys in node.js, without the need for ssh-keygen
or other external dependencies. The library supports RSA, DSA, ECDSA (nistp-*) and ED25519 key types, in both PEM (PKCS#1, PKCS#8) and OpenSSH formats.
To utilize SSHpk, one needs to first install it using the command npm install sshpk
. Once installed, you can use it in your code. Here are a few examples of how to use SSHpk:
var sshpk = require('sshpk');
var fs = require('fs');
var keyPub = fs.readFileSync('id_rsa.pub');
var key = sshpk.parseKey(keyPub, 'ssh');
console.log('Type =>', key.type);
console.log('Size =>', key.size);
console.log('Comment =>', key.comment);
var sshpk = require('sshpk');
var fs = require('fs');
var keyPem = fs.readFileSync('id_rsa.pem');
var key = sshpk.parseKey(keyPem, 'pem');
var sshpk = require('sshpk');
var fs = require('fs');
var keyPriv = fs.readFileSync('id_ecdsa');
var key = sshpk.parsePrivateKey(keyPriv, 'pem');
var data = 'some data';
var s = key.createSign('sha1');
s.update(data);
var signature = s.sign();
You'll notice that all examples begin with requiring both the sshpk
and the fs
modules. The fs
means file system, and it's what allows us to read the key files. Using the sshpk.parseKey
method, we can parse the key file and examine its details or use it for signing data.
The complete documentation for sshpk
library can be found directly in the README file on the GitHub repository, at https://github.com/joyent/node-sshpk. The documentation provides in-depth information about the different methods, properties, and options available with sshpk
. You will find detailed examples and explanations for using this library effectively.