【发布时间】:2015-06-05 02:49:02
【问题描述】:
我在运行这些命令时遇到了问题。
远程服务器希望通过yes 在RSA 文件中添加密钥,因为第一次与scp 建立连接。
命令如下
#!/bin/bash
scp -P58222 root@IP:/root/K /N
/usr/bin/expect -c 'expect "\n" { expect "Are you sure you want to continue connecting (yes/no)?" }'
send "yes\r"
expect "$ "
send "exit\r"
实际上我在询问时必须在脚本中传递“是”
主机'ip地址(ip address)'的真实性无法确定。
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?
您确定要继续连接(是/否)?
我怎样才能摆脱这个问题?
与
scp -o StrictHostKeyChecking=no
它仍在询问。
【问题讨论】:
-
你可以将参数传递给 ssh/scp 告诉它不要问这个问题;无需使用
expect编写答案。 -
也就是说——您要告诉它自动回答“是”哪个特定问题?例如,如果这是一个未知主机密钥问题,那将有所帮助。
-
具体来说,
scp -q开启静默模式,无需确认。