manage ssh keys on the server side (can be used with ssh-key-widget)
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
index.js
package.json
readme.markdown

readme.markdown

SSH Key Manager

Manage public ssh keys in ~/.ssh/authorized_keys file.

Example

Adding a new key:

var sshManager = require('ssh-key-manager');
sshManager.addKey('pkrumins', 'asdasdasd21312123 (key)', function (err) {
    if (err) {
        console.log(err);
        return;
    }
});

Listing keys:

var sshManager = require('ssh-key-manager');
sshManager.listKeys('pkrumins', function (err, keys) {
    if (err) {
        console.log(err);
        return;
    }
    var i = 0;
    keys.forEach(function (key) {
        console.log(i, key);
        i++;
    });
});

Deleting a key by index:

var sshManager = require('ssh-key-manager');
sshManager.deleteKey('pkrumins', 0, function (err) {
    if (err) {
        console.log(err);
        return;
    }
    console.log('Key 0 deleted ok');
});

Deleting all keys:

var sshManager = require('ssh-key-manager');
sshManager.deleteAllKeys('pkrumins', function (err) {
    if (err) {
        console.log(err);
        return;
    }
    console.log('All keys deleted ok');
});

Methods

var sshManager = sshManager()

Return a new ssh manager instance.

sshManager.listKeys(username, function (err, keys) { ... })

List username's public keys in ~username/.ssh/authorized_keys.

sshManager.addKey(username, key, function (err) { ... })

Add a key to username's public keys in ~username/.ssh/authorized_keys.

sshManager.deleteKey(username, index, function (err) { ... })

Delete the key at index index from username's public keys in ~username/.ssh/authorized_keys.

sshManager.deleteAllKeys(username, function (err) { ... })

Delete all username's public keys in ~username/.ssh/authorized_keys.

Install

With npm do:

npm install ssh-key-manager

Use browserify to require('ssh-key-manager').

License

MIT