当我必须对下面的一台机器执行 ssh 命令时,如果我输入“是”,它就可以正常工作并且能够如下登录。
ssh root@192.168.1.177
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 ~ #
Run Code Online (Sandbox Code Playgroud)
我正在通过expect脚本尝试同样的事情,它会引发如下错误。
./expectscriptssh.sh 192.168.1.177
spawn ssh root@192.168.1.177
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).
Run Code Online (Sandbox Code Playgroud)
以下是我的期望脚本:
#!/usr/bin/expect -f
set VAR [lindex …Run Code Online (Sandbox Code Playgroud)