ssh test ip

var arr=[];
for(var i=0;i<255;++i){
    arr.push("10.110.80."+i);
}
for(var i=0;i<arr.length;++i){
    var ip=arr[i];
    testip(ip);
}
function testip(ip){
let password="xxxxxx";
NodeSSH = require('node-ssh')
ssh = new NodeSSH()    
ssh.connect({
  host: ip,
  username: 'root',
  port: 22,
  password,
  tryKeyboard: true,
  onKeyboardInteractive: (name, instructions, instructionsLang, prompts, finish) => {
      //console.log(prompts);
      if (prompts.length > 0 && prompts[0].prompt.toLowerCase().includes('password')) {
        finish(password)
      }
    }
}).then(function(conn){
    console.log(ip);
},function(err){

})
}

 

posted @ 2020-07-06 15:29  wolbo  阅读(219)  评论(0编辑  收藏  举报