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

Server publickey auth method stopped working #1289

Closed
gilad-deel opened this issue Apr 20, 2023 · 4 comments
Closed

Server publickey auth method stopped working #1289

gilad-deel opened this issue Apr 20, 2023 · 4 comments

Comments

@gilad-deel
Copy link

import {readFileSync} from 'fs';
import ssh2 from 'ssh2';

const server = new ssh2.Server({hostKeys: [readFileSync('host.key')]}, (client, info) => {
    console.log('connection', info);
    client.on('authentication', (context) => {
        console.log('authentication', context.username, context.method);
        switch (context.method) {
            case 'publickey':
                return context.accept();
        }
        context.reject();
    });
});
server.listen(2222, '0.0.0.0', function () {
    console.log('Listening on port ' + this.address().port);
});
$ ssh -p 2222 -i ~/.ssh/mykey [email protected]    
[email protected]'s password: 
Permission denied, please try again.
Listening on port 2222
connection {
  ip: '127.0.0.1',
  family: 'IPv4',
  port: 60678,
  header: {
    greeting: '',
    identRaw: 'SSH-2.0-OpenSSH_9.0',
    versions: { protocol: '2.0', software: 'OpenSSH_9.0' },
    comments: undefined
  }
}
authentication test none
authentication test keyboard-interactive
authentication test password

I'm using latest version of ssh2., I never receive a challenge for a public key. I've tried to login with several keys (RSA, DSA etc) - none is challenging the server.

What am I missing here?

Thanks.

@mscdex
Copy link
Owner

mscdex commented Apr 20, 2023

Perhaps there is something wrong with the key you're trying to use (e.g. permissions). You can try adding -vvv to your OpenSSH client command line, it might clue you in as to why it's not trying the key you've specified.

@giladno
Copy link

giladno commented Apr 22, 2023

Thanks @mscdex , I do notice now "no mutual signature algorithm" and found out SHA1 is deprecated. Generating ED25519 based keys did solve the problem - thanks a lot!

Reference: https://confluence.atlassian.com/bitbucketserverkb/ssh-rsa-key-rejected-with-message-no-mutual-signature-algorithm-1026057701.html

@mscdex
Copy link
Owner

mscdex commented Apr 22, 2023

The issue with the RSA key signature algorithm should be fixed soon, see #989.

@mscdex
Copy link
Owner

mscdex commented Apr 29, 2023

The aforementioned fix has now been committed and will be in a release soon.

@mscdex mscdex closed this as completed Apr 29, 2023
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

3 participants