Skip to content
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

Invalid Signature Error from SSH Server #85

Open
drewdh opened this issue Aug 31, 2022 · 0 comments
Open

Invalid Signature Error from SSH Server #85

drewdh opened this issue Aug 31, 2022 · 0 comments

Comments

@drewdh
Copy link

drewdh commented Aug 31, 2022

When adding the signature to an SSH message for the SSH_MSG_USERAUTH_REQUEST, I keep getting a SSH_MSG_USERAUTH_FAILURE with a server error about an invalid signature. I'm forming the signature contents based on the SSH spec using some helper functions from the SSHy package.

Is there perhaps an issue with how I am creating this signature?

    const decodedPublicKey = config.privateKey.toPublic().toString('ssh', { hashAlgo: 'sha512' }).split(' ')[1];
    const publicKey = atob(decodedPublicKey);

    var m = new SSHyClient.Message();
    m.add_bytes(String.fromCharCode(SSHyClient.MSG_USERAUTH_REQUEST));
    m.add_string(this.termUsername);
    m.add_string('ssh-connection');
    m.add_string('publickey');
    m.add_boolean(true); // has signature
    m.add_string('rsa-sha2-512'); // public key algorithm name
    m.add_string(publicKey); // public key

    // Create signature
    var sigMsg = new SSHyClient.Message();
    sigMsg.add_string(SSHyClient.kex.sessionId);
    sigMsg.add_bytes(String.fromCharCode(SSHyClient.MSG_USERAUTH_REQUEST));
    sigMsg.add_string(this.termUsername);
    sigMsg.add_string('ssh-connection');
    sigMsg.add_string('publickey');
    sigMsg.add_boolean(true); // has signature
    sigMsg.add_string('rsa-sha2-512');
    sigMsg.add_string(publicKey);
    const sigMsgString = sigMsg.toString();

    // Sign signature
    const sign = config.privateKey.createSign('sha512');
    sign.update(sigMsgString);
    const signature = sign.sign();

    m.add_string(atob(signatureToString)); // signature

    this.parceler.send(m);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant