shelldropbear

How to accept 'yes' from shell script "Are you sure you want to continue connecting (yes/no)?" using ssh. Without using StrictHostKeyChecking=no


I'm using ssh command to remotely executing a shell script with -o **StrictHostKeyChecking=no ** option to bypass the authentification:

ssh -o StrictHostKeyChecking=no root@$IP '/test-script'

However, I'm using a sh shell that does not support the StrictHostKeyChecking=no option:

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)? 

All the -o option for ssh I have are:

ssh -o help
ssh: Available options:
ExitOnForwardFailure
UseSyslog

So is there any way I can prompt the 'yes' for the 'Are you sure you want to continue connecting (yes/no)?' question on the remote host?

I tried the following options but none of them worked

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'

Is there any way I can run the ssh remote command, read the prompt and find this question 'Are you sure you want to continue connecting (yes/no)?' and just enter yes?

Thank you


Solution

  • Assuming this is dropbear's ssh client.

    From man dbclient

    -y
    Always accept hostkeys if they are unknown. If a hostkey mismatch occurs the connection will abort as normal.

    This should be the dropbear equivalent to -o StrictHostKeyChecking=no.