-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECC SSH keygen for cloud provisioning #2051
Comments
Are we sure that SSH2 can generate keypairs? If I'm looking at the right documentation (https://github.com/mscdex/ssh2-streams) it looks like it can load/parse existing private/public keys and optionally generate a public key based on a loaded private key. |
Oooh. Good point. I can only find Hmm. |
I think the main goal is shorter keys, and since SSH2 may not help I'll start checking out other possibilities. One that caught my eye - https://github.com/jaredly/ssh-keypair Nice simple wrapper around ssh-keygen, currently doesn't seem to support much configuration, but would be easy enough for us to tweak. |
Agreed! Closing this other issue, since these two are equivalent: |
So I tweaked that package - https://github.com/soycode/ssh-keypair It works (assuming your system
Note that the Anyway, as I said it does work and seems straightforward, and gives lovely short keys with ecdsa. I'll see if the maintainer of ssh-keypair is interested in merging this (it does change the API a bit to specify the type option), else we can fork and use if desired. |
So, that looks like a wrapper around the I think the probem, rather than key generation, is establishing an SSH connection with an ECC key. That's the missing piece in ssh2: |
Gotcha, well it looks like there isn't any particular alternative to ssh2 so hopefully we can get that to support it. As you said key generation is unlikely to be an issue, but in any case here's a pure node solution for it - https://www.npmjs.com/package/sshpk |
Seems like there has been some progress on this in ssh2-streams!: |
There's been a bunch of commits, e.g.: I tested this node: spun up an SSH server, generated some keys, and manually symlink-ed in the latest ssh2-streams but wasn't able to succesfully login:
|
For my own reference, how to test this stuff: docker run -ti -P 7000:22 ubuntu:latest /bin/bash
apt-get update && apt-get install -y openssh-server
/etc/init.d/ssh start
ssh-keygen -t ecdsa -b 256
cat ~/.ssh/id_ecdsa.pub >> ~/.ssh/authorized_keys
base64 -w 0 ~/.ssh/id_ecdsa ; echo
ssh bob@localhost -p 7000 |
Just to add my notes - I've been investigating, trying to get it working within uproxy/uproxy-lib, no success yet unfortunately. Whatever additional ecdsa support ssh2-streams has added may not be as simple as "just upgrade the package and it works" - also, we are depending more directly on ssh2 than ssh2-streams, so there may be something through that step as well. Will continue looking into it - on the plus side, when I generated invite URLs w/ecdsa the length came out to <500 characters. So, it'll be nice once it works at least! |
It looks like several recent releases of ssh2/ssh2-streams were cut, I'll give another look to see if we can get this working. |
Still not quite "just working", but not clear why. I'm going to focus on other more obviously tractable issues, but revisit this some to add logging and try to figure it out. |
Our choices for shorter keys are ECDSA and Ed25519: It seems we should prefer the latter, i.e. Ed25519:
In another window:
Save this to var Client = require('ssh2').Client;
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');
conn.exec('uptime', function(err, stream) {
if (err) throw err;
stream.on('close', function(code, signal) {
console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
conn.end();
}).on('data', function(data) {
console.log('STDOUT: ' + data);
}).stderr.on('data', function(data) {
console.log('STDERR: ' + data);
});
});
}).connect({
host: '172.17.0.1',
port: 7000,
username: 'root',
privateKey: require('fs').readFileSync('id_ed25519') // CHANGE THIS FOR ECDSA
}); Test it in Node.js like so: docker run --rm -ti -v `pwd`:/worker -w /worker mhart/alpine-node:4 node login.js At the time of writing, only ECDSA keys are supported and even they are only supported by Node 6+. Now...what about current versions of browserify? |
FWIW, we already use ECDSA for all our PGP needs via e2e and WebCrypto. |
To issue an ECDSA-based cloud server invite:
Right now, you'll see a message in the logs:
|
Currently used for SSH keygen. We can just use SSH2, which we use elsewhere.
The text was updated successfully, but these errors were encountered: