Solving round robin DNS name with SSH Server hosts

Howdy,

Recently I had a little issue with  DNS round robin pointing to different SSH Servers ( different fingerprints ) conflicting with known_hosts file.

Follow a little script I wrote to test expect.

Follow the example (;

———————cut———————-

#!/usr/bin/expect --

puts “Which server do you want connect?”
expect_user -re “(.*)\n”
send_user “\n”
set server $expect_out(1,string)
spawn -noecho host $server
expect -re “(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})”
set m1 $expect_out(1,string)
set m2 $expect_out(2,string)
set m3 $expect_out(3,string)
set m4 $expect_out(4,string)
puts “Which is your username?”
expect_user -re “(.*)\n”
send_user “\n”
set username $expect_out(1,string)
stty -echo
spawn -noecho ssh $username@$m1.$m2.$m3.$m4
expect “continue connecting” {send “yes\r”}
interact

 

————————-cut———————————–
Simple bash :
 echo “Type Hostname \n” ; ssh $(read g;host “$g”|awk -F’address ‘ ‘/address/ {print $2;exit}’)
Feel free to improve !
This entry was posted in Network, Tools and tagged , , , . Bookmark the permalink.