Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip incorrect ssh passwords

Tags:

ssh

ruby

I have a script that logs into 1000+ wireless units and audits and them. Some of their passwords have been changed. I would like to skip these units without specifically telling ruby which ips to skip. The script is multithreaded and gets hung up because when ruby sshes into a unit and uses the wrong password it will ask for the password and the whole script comes to a halt.

*How to skip or rescue wrong password attempts for ruby net/ssh

Net::SSH.start('ip','user',password: 'pass', paranoid: false) do |ssh|

end

with the incorrect password will prompt you like so

[email protected]'s password:
like image 766
Schylar Avatar asked Oct 15 '25 13:10

Schylar


2 Answers

In latest net-ssh (2.10.0.beta1), the new option :non_interactive was added to ignore the password prompt. Here are the details.

It works for me. For your case it should be

Net::SSH.start('ip','user',password: 'pass', paranoid: false, :non_interactive=>true) do |ssh|

end
like image 115
eggface Avatar answered Oct 18 '25 05:10

eggface


options = { password: password, number_of_password_prompts: 0, timeout: SSH_TIMEOUT }

try to use 'number_of_password_prompts: 0,', It may be perfect

like image 30
user5176411 Avatar answered Oct 18 '25 05:10

user5176411



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!