我使用 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 …Run Code Online (Sandbox Code Playgroud)