#!/usr/bin/expect
# version_number=2.15.1.0001
#
# Expect script to verify that "passwordless" ssh to MIC uOS is
# configured.
# The script:
#   * Spawns an ssh command which will execute a command on the MIC uOS
#   * If ssh asks whether to add the MIC's fingerprint to known_hosts
#     (i.e. expect "(yes/no?" respond with "yes\r")
#   * When ssh sends message saying MIC's fingerprint has been added
#     to "known_hosts." send "exit\r"
# If passwordless ssh to MIC uOS is already configured, the ssh
# command will be executed and the script will exit wihtout changing
# the ssh configuration.

set micnum [lindex $argv 0]
set timeout 1

#puts $micnum
spawn ssh root@$micnum "echo PASSED"
expect "(yes/no)?" {send "yes\r"}
expect "known hosts." {send "exit\r"}
