| 7 | | if $?.success? |
| 8 | | known = IO.readlines(ENV['HOME'] + '/.ssh/known_hosts') |
| 9 | | found, fport = host, port if known.include?(key) |
| | 7 | |
| | 8 | # Scan for a local host |
| | 9 | IO.popen('-') do |pipe| |
| | 10 | if pipe # parent |
| | 11 | fork { sleep 1; Process.kill 'ALRM', pipe.pid rescue nil } # timeout |
| | 12 | key = pipe.read |
| | 13 | |
| | 14 | Process.wait(pipe.pid) |
| | 15 | if $?.success? |
| | 16 | known = IO.readlines(ENV['HOME'] + '/.ssh/known_hosts') |
| | 17 | found, fport = host, port if known.include?(key) |
| | 18 | end |
| | 19 | else |
| | 20 | $stderr.close |
| | 21 | exec 'ssh-keyscan', host |
| | 22 | end |