2018-12-02 07:50:49 +00:00
|
|
|
# JWK to SSH (for node.js)
|
|
|
|
|
|
|
|
A minimal library to encode a JWK
|
|
|
|
as an SSH public key (`id_rsa.pub`).
|
|
|
|
|
|
|
|
Works for RSA and ECDSA public keys.
|
|
|
|
|
|
|
|
Features
|
|
|
|
========
|
|
|
|
|
|
|
|
< 75 lines of code | < 0.7kb gzipped | 1.5kb minified | 2.1kb with comments
|
|
|
|
|
|
|
|
* [x] SSH Public Keys
|
2018-12-11 07:15:13 +00:00
|
|
|
* [x] OpenSSH Private Keys
|
|
|
|
* [x] RSA Keys
|
|
|
|
* [x] EC Keys
|
2018-12-02 07:50:49 +00:00
|
|
|
* P-256 (prime256v1, secp256r1)
|
|
|
|
* P-384 (secp384r1)
|
|
|
|
* [x] Browser Version
|
|
|
|
* [Bluecrypt JWK to SSH](https://git.coolaj86.com/coolaj86/bluecrypt-jwk-to-ssh.js)
|
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
Note: the file size stats are for v1.0 which did not include private key packing.
|
|
|
|
I plan to go back and update the stats, but just know that it grew a little over 2x.
|
|
|
|
|
2018-12-02 07:50:49 +00:00
|
|
|
### Need JWK to SSH? PEM to SSH?
|
|
|
|
|
|
|
|
Try one of these:
|
|
|
|
|
|
|
|
* [jwk-to-ssh.js](https://git.coolaj86.com/coolaj86/jwk-to-ssh.js) (RSA + EC)
|
|
|
|
* [Eckles.js](https://git.coolaj86.com/coolaj86/eckles.js) (more EC utils)
|
|
|
|
* [Rasha.js](https://git.coolaj86.com/coolaj86/eckles.js) (more RSA utils)
|
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
### Need Alternate SSH Private Keys?
|
2018-12-02 07:50:49 +00:00
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
This library supports OpenSSH private keys.
|
2018-12-02 07:50:49 +00:00
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
* [x] OpenSSH
|
|
|
|
* [ ] Normal PKCS1 / SEC1 / PKCS8
|
|
|
|
* [x] Rasha.js
|
|
|
|
* [x] Eckles.js
|
|
|
|
* [ ] Putty
|
2018-12-02 07:50:49 +00:00
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
# Library Usage
|
2018-12-02 07:50:49 +00:00
|
|
|
|
|
|
|
You can also use it from JavaScript:
|
|
|
|
|
|
|
|
```js
|
|
|
|
var fs = require('fs');
|
|
|
|
var jwktossh = require('jwk-to-ssh');
|
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
var jwk = JSON.parse(fs.readFileSync("./privkey.jwk.json"));
|
2018-12-02 07:50:49 +00:00
|
|
|
var pub = jwktossh.pack({
|
|
|
|
jwk: jwk
|
|
|
|
, comment: 'root@localhost'
|
2018-12-11 07:15:13 +00:00
|
|
|
, public: true
|
2018-12-02 07:50:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
console.info(pub);
|
|
|
|
```
|
|
|
|
|
2018-12-11 07:15:13 +00:00
|
|
|
# CLI Usage
|
|
|
|
|
|
|
|
You can install `jwk-to-ssh` and use it from command line:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install -g jwk-to-ssh
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
jwk-to-ssh [keyfile] [comment] [public]
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
jwk-to-ssh pubkey.jwk.json
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
jwk-to-ssh privkey.jwk.json root@localhost
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
jwk-to-ssh privkey.jwk.json root@localhost public
|
|
|
|
```
|
|
|
|
|
2018-12-02 07:50:49 +00:00
|
|
|
Legal
|
|
|
|
-----
|
|
|
|
|
|
|
|
[jwk-to-ssh.js](https://git.coolaj86.com/coolaj86/jwk-to-ssh.js) |
|
|
|
|
MPL-2.0 |
|
|
|
|
[Terms of Use](https://therootcompany.com/legal/#terms) |
|
|
|
|
[Privacy Policy](https://therootcompany.com/legal/#privacy)
|