I have a bash script, that runs a few commands. These commands take input, and I'd like to be able to automate this, as the input is always the same.
Is it possible to send these lines, one a time, when asked for?
Y
{JustPressEnter}
{JustPressEnter}
{JustPressEnter}
yes
APassword
The full command is this (actual IP removed)
apt-get install ssh-client \
&& mkdir /var/www/.ssh/ \
&& chown www-data:www-data /var/www/.ssh/ \
&& sudo -u www-data ssh-keygen -t rsa \
&& cat /var/www/.ssh/id_rsa.pub | ssh root@1.2.3.4 'cat >> .ssh/authorized_keys' \
&& sudo -u www-data touch /var/www/.ssh/known_hosts \
&& sudo -u www-data ssh-keygen -R 1.2.3.4 \
&& sudo -u www-data ssh-keyscan -H 1.2.3.4 >> /var/www/.ssh/known_hosts