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);
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?