我使用 ssh 命令远程执行 shell 脚本,并使用 -o **StrictHostKeyChecking=no ** 选项来绕过身份验证:
ssh -o StrictHostKeyChecking=no root@$IP '/test-script'
Run Code Online (Sandbox Code Playgroud)
但是,我使用的 sh shell 不支持 StrictHostKeyChecking=no 选项:
root:~ Jeff$ ssh StrictHostKeyChecking=no root@$IP '/test-script'
Could not create directory '/home/root/.ssh'.
The authenticity of host '192.168.186.1 (192.168.186.1)' can't be established.
ECDSA key fingerprint is SHA256:KOx9T7VeRy9dJ2ug+tfnlbnG/7Fm0I5Tl/ziTkE4JaE.
Are you sure you want to continue connecting (yes/no)?
Run Code Online (Sandbox Code Playgroud)
我拥有的 ssh 的所有 -o 选项是:
ssh -o help
ssh: Available options:
ExitOnForwardFailure
UseSyslog
Run Code Online (Sandbox Code Playgroud)
那么有什么方法可以提示“您确定要继续连接(是/否)吗?”的“是”?关于远程主机的问题?
我尝试了以下选项,但没有一个起作用
ssh -o StrictHostKeyChecking=no root@$IP '/test-script' | yes
yes | ssh StrictHostKeyChecking=no root@$IP '/test-script'
yes yes | ssh StrictHostKeyChecking=no root@$IP '/test-script'
Run Code Online (Sandbox Code Playgroud)
有什么方法可以运行 ssh 远程命令,阅读提示并找到这个问题“您确定要继续连接吗(是/否)?” 然后输入 yes?
谢谢
假设这是 dropbear 的 ssh 客户端。
-y
如果主机密钥未知,则始终接受主机密钥。如果发生主机密钥不匹配,连接将正常中止。
这应该是相当于 的 dropbear -o StrictHostKeyChecking=no。