when I have to do ssh to one of my machine below is the command and if I type 'yes' it is working and able to login as below.
ssh [email protected]
The authenticity of host '192.168.1.177 (192.168.1.177)' can't be established.
ED25519 key fingerprint is SHA256:KqI6oKKY1JOH+OJZzCYObPdkMVNNwhkaMGTYgx/fDxE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.177' (ED25519) to the list of known hosts.
localhost ~ #
Same thing I am trying through expect script and it throws me error as below.
./expectscriptssh.sh 192.168.1.177
spawn ssh [email protected]
invalid command name "fingerprint"
while executing
"fingerprint"
invoked from within
"expect "Are you sure you want to continue connecting (yes/no/[fingerprint])? ""
(file "./expectscriptssh.sh" line 4).
Below is my expect script:
#!/usr/bin/expect -f
set VAR [lindex $argv 1]
spawn ssh root@$argv
expect "Are you sure you want to continue connecting (yes/no/[fingerprint])? "
send "yes\r"
Can any body suggest, how can I resolve this.
expect
patterns regular expressions? In that case,)?
is not matching a question mark after a right parentheses, but says "match an optional)
". Likewise[fingeprint]
would match one of the characters in[...]
. Even if they are only globbing patterns,[fingerprint]
would cause an issue for you.-re
as a switch to enable them.