SSH to JWK (for node.js)
A minimal library to parse an SSH public key (id_rsa.pub
)
and convert it into a public JWK.
Works for RSA and ECDSA public keys.
Features
< 100 lines of code | <1kb gzipped | 1.8kb minified | 3.1kb with comments
- SSH Public Keys (RFC 4253)
- fingerprint
- OpenSSH Private Keys
- RSA
- 2048, 3072, 4096
- EC Public Keys
- P-256 (prime256v1, secp256r1)
- P-384 (secp384r1)
- Browser Version
Note: Lines of code have increased by about 2x since adding private key support.
Need JWK to SSH? SSH to PEM?
Try one of these:
- jwk-to-ssh.js (RSA + EC)
- Eckles.js (more EC utils)
- Rasha.js (more RSA utils)
Need SSH Private Keys?
Many SSH private keys are just normal PEM files, so you can use Eckles or Rasha, as mentioned above.
As for the OpenSSH-specific Private Keys, both EC and RSA are fully supported.
CLI
You can install ssh-to-jwk
and use it from command line:
npm install -g ssh-to-jwk
ssh-to-jwk ~/.ssh/id_rsa.pub
ssh-to-jwk ~/.ssh/id_rsa
Usage
You can also use it from JavaScript:
SSH to JWK
var fs = ;var sshtojwk = ;var ssh; ssh = sshtojwk;console; // For OpenSSH PEMs only, use Rasha for standard RSA or Eckles for standard ECssh = sshtojwk;console;
SSH Fingerprint
var fs = ;var sshtojwk = ;var pub = fs; sshtojwk;
Legal
ssh-to-jwk.js | MPL-2.0 | Terms of Use | Privacy Policy