I want to call a command with a script using dash. here is my code:
#!/bin/sh
ip='172.45.0.219'
cmd1='yes yes'
cmd2="./ssh foo@$ip"
eval $cmd1 | $cmd2
when I run my script this is my output:
Pseudo-terminal will not be allocated because stdin is not a terminal.
The authenticity of host '172.45.0.219 (172.45.0.219)' can't be established.
ECDSA key fingerprint is SHA256:PpEShWXU3zQhkyAsy4Zd1Jddb2lW0ULautIdPMr8yxA.
Are you sure you want to continue connecting (yes/no)?
and waiting for a 'yes/no'. I want this script get 'yes' automatically.
I try some other ways like this:
eval echo yes | $cmd2
and get the same result. Thanks for any help.
In this case, the user must be authenticated and the solution is:
#!/bin/sh
ip='172.45.0.219'
cmd="ssh-keyscan -H $ip >> ~/.ssh/known_hosts"
eval $cmd
However, this is not the real answer of this question.