63 lines
1.4 KiB
Markdown
63 lines
1.4 KiB
Markdown
# SSH Fingerprint (for node.js)
|
|
|
|
A minimal library to read an SSH public key (`id_rsa.pub`)
|
|
and generate its fingerprint.
|
|
|
|
Works for RSA and ECDSA public keys.
|
|
|
|
Features
|
|
========
|
|
|
|
< 100 lines of code | <1kb gzipped | 1.8kb minified | 3.1kb with comments
|
|
|
|
* [x] SSH Public Key SHA256 Fingerprints
|
|
* RSA (2048-bit, 3072-bit, 4096-bit)
|
|
* EC / ECDSA
|
|
* P-256 (prime256v1, secp256r1)
|
|
* P-384 (secp384r1)
|
|
* [x] Browser Version
|
|
* [Bluecrypt SSH Fingerprint](https://git.coolaj86.com/coolaj86/bluecrypt-ssh-fingerprint.js)
|
|
|
|
# CLI
|
|
|
|
You can install `ssh-fingerprint` and use it from command line:
|
|
|
|
```bash
|
|
npm install -g ssh-fingerprint
|
|
```
|
|
|
|
```bash
|
|
ssh-fingerprint ~/.ssh/id_rsa.pub
|
|
```
|
|
|
|
```
|
|
2048 SHA256:yCB62vBVsOwqksgYwy/WDbaMF2PhPijAwcrlzmrxfko root@localhost (RSA)
|
|
```
|
|
|
|
(the output is the same as `ssh-keygen -lf ~/.ssh/id_rsa.pub`)
|
|
|
|
# Usage
|
|
|
|
You can also use it from JavaScript:
|
|
|
|
**SSH Fingerprint**
|
|
|
|
```js
|
|
var fs = require('fs');
|
|
var SSH = require('ssh-fingerprint');
|
|
var pub = fs.readFileSync("./id_rsa.pub");
|
|
|
|
SSH.fingerprint({ pub: pub }).then(function (fing) {
|
|
console.info('The key fingerprint is:');
|
|
console.info(fing.fingerprint, fing.comment);
|
|
// SHA256:yCB62vBVsOwqksgYwy/WDbaMF2PhPijAwcrlzmrxfko root@localhost
|
|
});
|
|
```
|
|
|
|
# Legal
|
|
|
|
[ssh-fingerprint.js](https://git.coolaj86.com/coolaj86/ssh-fingerprint.js) |
|
|
MPL-2.0 |
|
|
[Terms of Use](https://therootcompany.com/legal/#terms) |
|
|
[Privacy Policy](https://therootcompany.com/legal/#privacy)
|