最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

错误:所有配置的身份验证方法都失败:'client

IT培训 admin 5浏览 0评论

错误:所有配置的身份验证方法都失败:'client

我正在使用node.js ssh2模块。我已经通过执行命令'npm install ssh2'安装了ssh2模块。但是,当我使用ssh2连接到远程服务器时,它总是输出错误:[错误:所有配置的身份验证方法失败]级别:'客户端身份验证'

这是我的代码

var Client = require('ssh2').Client
var conn = new Client();
var option = {
    host: '10.171.65.154',
    port: 22,
    username: 'root',
    password: '123456'
};

conn.on('ready', function(){
    console.log('Client :: ready');
    conn.sftp(function(err, sftp){
        if(err) throw err;
        sftp.readdir('home', function(err, list){
            if(err) throw err;
            console.dir(list);
            conn.end();
        });
    });
}).on('error', function(err){
    console.log(err);
}).connect(option);

但是,我无法成功连接。我确信用户名和密码是正确的,我可以通过SecureCRT成功连接。

它总是输出错误:[错误:所有配置的身份验证方法都失败]级别:'client-authentication'

回答如下:

可能,您必须处理键盘交互式身份验证(与密码不同)。尝试这样的事情:

connection.on('ready', function(){
    console.log("Connected!");
}).on('error', function(err){
    console.error(err);
}).on('keyboard-interactive', function (name, descr, lang, prompts, finish) {
    // For illustration purposes only! It's not safe to do this!
    // You can read it from process.stdin or whatever else...
    var password = "your_password_here";
    return finish([password]);

    // And remember, server may trigger this event multiple times
    // and for different purposes (not only auth)
}).connect({
    host: "your.host.or.ip",
    port: 22,
    username: "your_login",
    tryKeyboard: true
});

错误:所有配置的身份验证方法都失败:'client

我正在使用node.js ssh2模块。我已经通过执行命令'npm install ssh2'安装了ssh2模块。但是,当我使用ssh2连接到远程服务器时,它总是输出错误:[错误:所有配置的身份验证方法失败]级别:'客户端身份验证'

这是我的代码

var Client = require('ssh2').Client
var conn = new Client();
var option = {
    host: '10.171.65.154',
    port: 22,
    username: 'root',
    password: '123456'
};

conn.on('ready', function(){
    console.log('Client :: ready');
    conn.sftp(function(err, sftp){
        if(err) throw err;
        sftp.readdir('home', function(err, list){
            if(err) throw err;
            console.dir(list);
            conn.end();
        });
    });
}).on('error', function(err){
    console.log(err);
}).connect(option);

但是,我无法成功连接。我确信用户名和密码是正确的,我可以通过SecureCRT成功连接。

它总是输出错误:[错误:所有配置的身份验证方法都失败]级别:'client-authentication'

回答如下:

可能,您必须处理键盘交互式身份验证(与密码不同)。尝试这样的事情:

connection.on('ready', function(){
    console.log("Connected!");
}).on('error', function(err){
    console.error(err);
}).on('keyboard-interactive', function (name, descr, lang, prompts, finish) {
    // For illustration purposes only! It's not safe to do this!
    // You can read it from process.stdin or whatever else...
    var password = "your_password_here";
    return finish([password]);

    // And remember, server may trigger this event multiple times
    // and for different purposes (not only auth)
}).connect({
    host: "your.host.or.ip",
    port: 22,
    username: "your_login",
    tryKeyboard: true
});
发布评论

评论列表 (0)

  1. 暂无评论