当以下语句在执行Expect Shell脚本时出现时,我希望自动提供“是”,或者忽略它,并以安全的方式进行操作。
#!/usr/bin/expect
spawn ssh $user@$host不能确定宿主abcdef(10.566.1.98)的真实性。RSA密钥指纹是jk:94:ba:93:0b:eb:ff:df:ea:gh:hj:23:3c:hj:9c:be.您确定要继续连接(是/否)吗?
发布于 2015-02-12 04:54:15
在这个场景中使用exp_continue。
#!/usr/bin/expect
set prompt "#|>|\\\$"
spawn ssh dinesh@myhost
expect {
#If 'expect' sees '(yes/no )', then it will send 'yes'
#and continue the 'expect' loop
"(yes/no)" { send "yes\r";exp_continue}
#If 'password' seen first, then proceed as such.
"password"
}
send "root\r"
expect -re $prompt参考资料:期望
发布于 2019-08-21 12:18:01
这是可行的,而且对于码头建造来说特别方便
ssh-keyscan hostname.example.com >> $HOME/.ssh/known_hostshttps://stackoverflow.com/questions/28461713
复制相似问题