I am writing the following expected script to automate ssh login to a remote Linux machine And run the command "cat / etc / APP_VERSION.txt file"
I once did not ask from the ssh team about -
"Are you sure you want to continue connecting (yes/no)?"
So, in this case, the first wait is still waiting for the string "(yes / no)?" - (
And do not continue the second wait - "password:"?
How to resolve this ?,
I mean, if the line "Are you sure you want to continue the connection (yes / no)?" Is not appears from ssh
Then we should move on to the next wait for "password:", but how to do it?
note1 - in the case of the question "Do you really want to continue the connection (yes / no)?" appears, then waiting for the script works fine without problems.
note2 - I cannot use a positive timeout value (like timeout 10) because ssh itself has a delay
. ,,.
My wait script: (this wait is part of my ksh script)
. . . APP_MACHINE=172.12.6.190 set timeout -1 spawn ssh $APP_MACHINE expect { "(Are you sure you want to continue connecting yes/no)?" { send "yes\r" } } expect password: {send PASS123\r} expect > {send "cat /etc/APP_VERSION.txt\r"} expect > {send exit\r} expect eof . . .
. ,,,.
ssh example from my linux machine
ssh APP_MACHINE The authenticity of host 'APP_MACHINE (172.12.6.190 )' can't be established. RSA key fingerprint is 1e:8a:3d:b3:e2:8c:f6:d6:1b:16:65:64:23:95:19:7b. Are you sure you want to continue connecting (yes/no)?
user1121951
source share