steelbrain / steelbrain/node-ssh

Issue with Error: All configured authentication methods failed

Open
#258 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1k
Forks
94
PR merge metrics
No merged PRs in 30d

Description

Hi there,

I'm trying to use your library to connect to a server via ssh but having some trouble. I'm stumbling on the Error: All configured authentication methods failed error message. However, when I try to connect with using ssh2 library by itself, it has no issue.

This example is how I connect using ssh2 library...

const connectionOptions = {
            host: hostname,
            port: port,
            username: username,
            privateKey: require('fs').readFileSync(path.resolve(__dirname, privateKeyLocation))
        };

        var conn = new Client();
        conn.on('ready', function () {
            conn.shell(function (err, stream) {
                if (err) {
                    return err;
                } else {
                    stream.on('close', function () {
                        console.log('Stream :: close');
                        conn.end();
                    }).on('data', function (data) {
                        console.log('OUTPUT: ' + data);
                    });
                    stream.end(commands);
                }

            });

        }).connect(connectionOptions);

This example is how I'm trying to use node-ssh. I also had an issue with the privateKey not being a string but it connects fine in first example without toString() method.

const connectionOptions = {
            host: hostname,
            port: port,
            username: username,
            privateKey: require('fs').readFileSync(path.resolve(__dirname, privateKeyLocation)).toString()
        };

        await ssh.connect(connectionOptions)
        const defaultDirectory = await ssh.exec('pwd', [], {
            stream: 'stdout'
        })
        const shellStream = await ssh.requestShell()

        const stdin = process.openStdin();
        stdin.addListener('data', (data) => {
            console.log('current path is', defaultDirectory)
            // Trim input to prevent the endings of lines in Windows ('\r\n\')
            shellStream.write(data.toString().trim() + '\n')
        })
        shellStream.on('data', (data) => {
            process.stdout.write(data)
        })
        shellStream.stderr.on('data', (data) => {
            process.stdout.write(data)
        })

I'm aware this error is common in Linux, but seems to only happen after I use this library. Could you point me in the right direction?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is identified. Compare the two connection examples, focusing on the authentication options passed to node-ssh versus ssh2; done would require a reproducible diagnosis or documented fix for the authentication failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.