2016-08-22 2 views
0

일부 시스코 장치를 관리하기 위해 노드를 사용하고 있으며 최근 이틀 동안 해결할 수 없었던 문제가 발생했습니다.node.js ssh2shell wrapper가 시스코 장치에 로그인하지 못했습니다.

SSH2 모듈을 사용하여 Cisco 장비에서 명령을 실행하고 실행할 수 있지만 한 번에 하나의 명령 만 실행하도록 제한하고 있습니다. 후속 명령의 경우 새 연결을 설정 한 다음 다른 명령을 실행해야합니다. 이것은 내 필요에 맞지 않습니다.

일부 답변을 읽고 SSH2 용 SSH2Shell 래퍼를 사용하여 여러 명령을 순차적으로 실행할 수 있으므로 시작했습니다. 하지만 SSH2Shell을 사용하면 클라이언트에서 제공하는 암호가 서버에서 지원되는 암호와 일치하지 않기 때문에 시스코 장치에 연결할 수 없습니다. SSH2 모듈에도 동일한 문제가 있었지만 Cipher와 KEX를 추가하여 해결할 수있었습니다. SSh2Shell에서 동일한 작업을 수행하면 작동하지 않습니다. 여러 다른 방법으로 다른 장소에 추가하려고 시도했지만 연결되지 않습니다.

나는 올바른 길을 가고 있다고 생각하는데, 나는 Ciphers와 KEX를 추가 할 적절한 위치를 모른다. 난이 실행할 때 단말기에 '폐쇄'다음 '접속'얻을

var host = { 
    server:  { 
      host:   "<host IP>", 
      port:   "22", 
      userName:  "<username>", 
      password: "<password>" 
     }, 
     connection:   require ('ssh2'), 
     commands:  [ 
      "show version", 
      "show ssh" 
     ], 
     algorithms: { 
      kex: [ 
       'diffie-hellman-group1-sha1', 
       'ecdh-sha2-nistp256', 
       'ecdh-sha2-nistp384', 
       'ecdh-sha2-nistp521', 
       'diffie-hellman-group-exchange-sha256', 
       'diffie-hellman-group14-sha1'], 
      cipher: [ 
       'aes128-ctr', 
       'aes192-ctr', 
       'aes256-ctr', 
       'aes128-gcm', 
       '[email protected]', 
       'aes256-gcm', 
       '[email protected]', 
       'aes256-cbc' 
      ] 
     }, 
     msg: { 
      send: function(message) { 
      console.log("message: " + message); 
      } 
     }, 
    verbose: true, 
    debug:    true, 
    idleTimeOut:   15000, 
    connectedMessage: "connected", 
    readyMessage:  "ready", 
    closedMessage:  "closed", 

    onCommandComplete: function(command, response, sshObj) { 

     console.log("------------- onCommandComplete ---------"); 
     console.log(command + ": " + response); 
    }, 
    onEnd: function(sessionText, sshObj) { 
     console.log("--------- onEnd has ------------"); 
     console.log(sessionText); 
    } 
}; 



//Create a new instance 
var SSH2Shell = require ('ssh2shell'), 
    SSH  = new SSH2Shell(host); 

//Start the process 
SSH.connect(); 

:

여기 SSH2Shell 내 코드이다. 시스코 라우터에서 디버깅 내 암호가 일치하지 않는 것을 보여줍니다.

8 22 22 12:06:59 % SSH-3-NO_MATCH : 일치하는 암호가 없습니다. 클라이언트 aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm, aes128-gcm @ openssh.com, aes256 -gcm, AES256-GCM @ openssh.com 서버 AES128-CBC, 3DES-CBC, AES192-CBC, AES256-CBC

답변

0

SSH2Shell 용 Github에 문제가 기록되었으며 "cmp-202"작성자 덕분에이 문제가 해결되었습니다. 다음은 Cipher와 KEX를 제공하는 스크립트 사본입니다. "키보드 - 대화 형"이벤트가 구현 된 SSH2Shell 버전 1.5.1에서 추가 문제가 발견되어 해결되었습니다. 아래 스크립트는 사용자 정의 암호와 "키보드 상호 작용"이벤트를 모두 사용합니다.

var host = { 
    server: { 
     host: "<hostname or IP>", 
     port: "22", 
     userName: "<username>", 
     password: "<password>", 
     hashMethod:  "md5", 
     readyTimeout: 50000, 
     tryKeyboard: true, 
     algorithms: { 
     kex: [ 
      'diffie-hellman-group1-sha1', 
      'ecdh-sha2-nistp256', 
      'ecdh-sha2-nistp384', 
      'ecdh-sha2-nistp521', 
      'diffie-hellman-group-exchange-sha256', 
      'diffie-hellman-group14-sha1'], 
     cipher: [ 
      'aes128-ctr', 
      'aes192-ctr', 
      'aes256-ctr', 
      'aes128-gcm', 
      '[email protected]', 
      'aes256-gcm', 
      '[email protected]', 
      'aes256-cbc' ] 
     } 
     }, 
     commands: [ 
     "show deviceport global", 
     "show deviceport names" ], 
     msg: { 
     send: function(message) { 
      console.log("message: " + message); 
     } 
     }, 
     verbose: true, 
     debug: true, 
     idleTimeOut: 10000, 
     ["keyboard-interactive"]: function(name, instructions, instructionsLang, prompts, finish){ 
     console.log('Connection :: keyboard-interactive'); 
     console.log(prompts); 
     finish(["<password>"]); 
     }, 
     onEnd: function(sessionText, sshObj) { 
     sshObj.msg.send("--------- onEnd has ------------"); 
     sshObj.msg.send(sessionText); 
     } 

}; 

//Create a new instance 
var SSH2Shell = require ('ssh2shell-ssh2.connect-options'), 
SSH = new SSH2Shell(host); 

//Start the process 
SSH.connect(); 

이 방법을 사용하면 시간을 절약 할 수 있기를 바랍니다.

0

ssh2shell 모듈은 ssh2에 특정 옵션을 전달하는 것, 그래서 그것은 algorithms 옵션을 통과하지 않습니다 에. 프로젝트 이슈 트래커에 문제를 제출할 수 있습니다.

+0

감사합니다. mscdex. 내가 할게. – Pankaj

관련 문제