2016-08-22 15 views
0

私はいくつかのシスコデバイスを管理するためにnodeを使用しています。私は過去2日間で解決できなかった問題にぶつかっています。node.js ssh2shellラッパーがciscoデバイスへのログインに失敗しました

SSH2モジュールを使用すると、Ciscoギアでコマンドを接続して実行できますが、これは一度に1つのコマンドだけを実行するように制限しています。フォローアップコマンドでは、新しい接続を確立してから別のコマンドを実行する必要があります。これは私のニーズにはうまくいかない。

私はSSH2用のSSH2Shellラッパーを使い始めました。複数のコマンドを連続した順序で実行できるようになったからです。しかし、SSH2Shellを使用すると、クライアントが提供する暗号がサーバでサポートされているものと一致しないため、Cisco機器との接続を確立できません。 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のための私のコードです。シスコルータでデバッグすると、私の暗号が一致しないことがわかります。

Aug 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

関連する問題