2

I have a script, that is running inside the docker container some actions we need for some internal debugging purposes:

set -eu
echo "Starting i/o test for host"
IP_HOST=$(ip a | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | grep 172.17 | awk 'NR==1{print $1}')
echo "Detected IP of host is $IP_HOST"
sshpass -p tcuser ssh -o StrictHostKeyChecking=no docker@localhost -t -t
echo "Then"

the output here produce exactly:

bash-5.0# sh /etc/cron.d/iotesthost.sh
Mon Mar  2 12:43:59 UTC 2020
Starting i/o test for host
Detected IP of host is 172.17.0.1
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
   ( '>')
  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-\)           www.tinycorelinux.net

and as the last line is reached, the script makes me exiting bash or crond execution. So I can't go ahead with processing other lines after sshpass/ssh, so I never reach echo "Then"

That is the reason of exiting the script execution and how to work it around, still keeping all the features of accepting keys (i need is as each time the docker container calls for the script it is new)

If I ignore -t -t, I'm getting error according to https://stackoverflow.com/a/7122115/1759063

Eljah
  • 4,188
  • 4
  • 41
  • 85
  • 1
    It's not clear what you want the script to do. It looks like ssh is successfully connecting to the remote host. Do you want ssh to exit immediately? Do you want to run a command on the remote host? Is the `echo` command supposed to run on the remote host? – Kenster Mar 02 '20 at 13:34
  • @Kenster right, echo is just a test line, but instead some dd command execution should be called on the host – Eljah Mar 02 '20 at 17:14
  • but for now the problem is to get no matter what kind of script execution after the ssh into the host – Eljah Mar 02 '20 at 17:15

1 Answers1

2

see https://askubuntu.com/questions/87449/how-to-disable-strict-host-key-checking-in-ssh

or

echo "StrictHostKeyChecking no" >> /etc/ssh_config

for a global solution. Please note that there is no security check anymore then.

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186