Expect script to handle RSA finger print keys
<p>I am trying to make my expect script more robust and to be able to handle more situations to be more automated. Currently my script works fine, however, there are times where I will be asked to add the RSA keys to known_hosts, I want this to default to yes all the time. My server doesn't always ask for the keys, once added then after awhile it wont ask until you delete the keys or switch gatways. After looking online i have tried to add this (commented code) in my working code and after added that it stalls at password input screen <strong>if RSA key had been added already.</strong></p>

<p>So my question is, is there a way to handle this situation lets say if RSA has been added already, it will just skip to the password line?</p>

<pre><code>[user@gateway my_direcotry]$ cat loadItTest
#!/usr/bin/expect -f

set timeout 600
set user root
set host 1.1.1.1
set pass pass


spawn ssh $user@$host

#expect {
#    -re "RSA key fingerprint" {send "yes\r"}
#}

expect "assword:"
send "$pass\r"
expect "#"
</code></pre>

<p>Sample output:</p>

<pre><code>[root@gateway my_direcotry]# loadItTest
spawn ssh root@1.1.1.1
root@1.1.1.1's password:
</code></pre>