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

2

There are 2 answers

4
Olaf Dietsche On BEST ANSWER

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.

0
Abdull On

Try -o StrictHostKeyChecking=accept-new. From the OpenSSH documentation on StrictHostKeyChecking:

If this flag is set to accept-new then ssh will automatically add new host keys to the user's known_hosts file, but will not permit connections to hosts with changed host keys.

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