79714127

Date: 2025-07-25 02:16:01
Score: 1
Natty:
Report link

I have find answer with set failure ssh and create an other

spawn ssh -o StrictHostKeyChecking=no $username\@$host
expect {
    timeout { send_user "\nTimeout Exceeded - Check Host\n"; set first_attempt_failed 1 }
    eof { send_user "\nSSH Connection To $host Failed\n"; set first_attempt_failed 1 }
    "*#" {}
    "*assword:" {
            send "$password\n"
    }
}

if { [info exists first_attempt_failed] && $first_attempt_failed == 1 } {
        spawn ssh -o KexAlgorithms=diffie-hellman-group1-sha1 -o StrictHostKeyChecking=no $username@$host
        expect {
                timeout { send_user "\nTimeout Exceeded - Check Host\n"; exit 1 }
                eof { send_user "\nSSH Connection To $host Failed\n"; exit 1 }
                "*#" {}
                "*assword:" {
                        send "$password\n"
                }
        }
}

Thanks

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Yohan Oc