how can i input the password use keyboard-interactive

Abierto
#385 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
javascript, node.js, typescript

Línea de trabajo

Reproduce el fallo con las opciones de conexión de node-ssh proporcionadas y, después, lee el manejo de autenticación de node-ssh y el flujo de su cliente ssh2 incluido. Compara el comportamiento documentado de onKeyboardInteractive y tryKeyboard con el ejemplo de authHandler. Se considera terminado cuando se alcanza el callback de keyboard-interactive y el reintento de contraseña se completa sin el error de autenticación del cliente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

env

i want to connet to the different host, some of them no config the no password login,so i need to try to connect the host no password firstly, if faild ,i'll use prompts ask the user to input the password to retry.

ssh2

when i use ssh2 to achieve it, the code like this:

conn.on('ready', () => {
 // some code
}).connect({
    host,
    port: 22,
    username,
    tryKeyboard: true,
    authHandler: (methodsLeft, partialSuccess, callback) => {
      prompts([{
        type: 'password',
        name: 'newPassword',
        message: `input the password of ${hostItem}:`,
      }]).then(({newPassword}) => {
        callback({type: 'password', username, password: newPassword})
      })
    },
 })

the code workd very well

node-ssh

the ssh2 hard to exec the multiple command on one connect. but the node-ssh is easy to do that.
when i try to connect , the problem was happen,

 Error: All configured authentication methods failed
    at doNextAuth (E:\workSpace\my-project-name\node_modules\node-ssh\node_modules\ssh2\lib\client.js:413:17)
    at tryNextAuth (E:\workSpace\my-project-name\node_modules\node-ssh\node_modules\ssh2\lib\client.js:484:5)
    at SSH2Stream.onUSERAUTH_FAILURE (E:\workSpace\my-project-name\node_modules\node-ssh\node_modules\ssh2\lib\client.js:597:5)
    at SSH2Stream.emit (events.js:310:20)
    at parsePacket (E:\workSpace\my-project-name\node_modules\ssh2-streams\lib\ssh.js:3682:10)
    at SSH2Stream._transform (E:\workSpace\my-project-name\node_modules\ssh2-streams\lib\ssh.js:701:13)
    at SSH2Stream.Transform._read (_stream_transform.js:191:10)
    at SSH2Stream._read (E:\workSpace\my-project-name\node_modules\ssh2-streams\lib\ssh.js:253:15)
    at SSH2Stream.Transform._write (_stream_transform.js:179:12)
    at doWrite (_stream_writable.js:442:12) {
  level: 'client-authentication'
}

from other issus i knew the authHandler not support so i tyied the onKeyboardInteractive, but obviously,it not be called ,because i can't see the console mark.
my code are following:

ssh.connect({
    host,
    username,
    port: 22,
    tryKeyboard: true,
    debug: console.log(),
    onKeyboardInteractive(name, instructions, instructionsLang, prompts, finish) {
      console.log('🔊🚀🚀🚀🔊 ~ RollbackCommand ~', prompts)
      if (prompts.length > 0 && prompts[0].prompt.toLowerCase().includes('password')) {
        prompts([{
          type: 'password',
          name: 'newPassword',
          message: `input the password of ${hostItem}:`,
        }]).then(({newPassword}) => {
          finish([newPassword])
        })
      }
    },
    })

i'm a newcoming ,so i'm not sure it's my code error or i use this API in wrong way.
i need some help, thx

Lenguaje dominante
TypeScript
Estrellas
1k
Forks
94
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de steelbrain/node-ssh

Todos los issues de steelbrain/node-ssh

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.