Skip to content

manage ssh keys on the server side (can be used with ssh-key-widget)

Notifications You must be signed in to change notification settings

mikamaunula/ssh-key-manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

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

About

manage ssh keys on the server side (can be used with ssh-key-widget)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%