How to use the ssh2.utils.genPublicKey function in ssh2

To help you get started, we’ve selected a few ssh2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hmngwy / weblog.sh / lib / ssh / auth.js View on Github external
User.findOne({username: ctx.username}, function(err, doc){

      if (doc) {

        if (ctx.method === 'publickey'
         && ctx.username!=undefined
         && doc.publicKey
         && doc.publicKey.length !== 0) {
          console.log(' **  trying key auth');

          //load publickey by username
          if(doc.publicKey && doc.publicKey.length) {

            var publicKey = utils.genPublicKey(utils.parseKey(doc.publicKey));

            var successfulKeyAuth = ctx.key.algo === publicKey.fulltype
              && buffersEqual(ctx.key.data, publicKey.public);

            if (successfulKeyAuth) {
              // user logged in via key, serve interface
              console.log('[ok] key auth');
              userMeta.next = 'auth';
              userMeta.user = doc;
              ctx.accept();
            } else {
              console.log('[no] key auth');
              return ctx.reject();
            }

          } else {
github kzwang / node-git-lfs / lib / authenticator / basic.js View on Github external
constructor(options) {
        super();
        this._options = options || {};
        var clientPublicKeyPath = _.get(options, 'client_public_key');
        if (clientPublicKeyPath) {
            this.clientPublicKey = ssh_utils.genPublicKey(ssh_utils.parseKey(fs.readFileSync(clientPublicKeyPath)));
        }
    }