Generate Well-formed SSH Key In JavaScript
Solution 1:
SSH keys are not just random strings of characters, so that's why they don't pass verification.
This library here called Javascript Cryptography Toolkit can help you generate RSA keys (used by SSH).
They have a demo of generating the key: https://github.com/ats4u/titaniumcore/blob/master/crypto/RSA.sample1.html
As you can see from the source code of the demo page, the toolkit is quite heavy weight, but if that's what you need, then that's what you have to use, I guess. Ofcourse it would have been much simpler to just offload key generation to the server, but if you are writing a client side only library, then you have to stick with this.
2019 update: updated links to github.
Solution 2:
If you end up making an AJAX call to your existing lightweight Ruby Sinatra app to generate and retrieve an SSH key, you can use the sshkey Gem to do so https://rubygems.org/gems/sshkey
This doesn't answer how to do it in pure JavaScript but provides an alternate avenue based on your specific application architecture (see comments below question).
Post a Comment for "Generate Well-formed SSH Key In JavaScript"