I am trying to make the following script work for the ufw
command which is expecting me to press y or n to confirm my command. In addition I want to pass my password to the sudo
command (I know, bad idea).
echo 'y' | { echo 'my password'; } | sudo ufw reset
The sudo
password bit works but I get the following error message from the ufw reset
command:
Resetting all rules to installed defaults. Proceed with operation (y|n)? Aborted
The command is being aborted rather than accepting the 'y' I was trying to send it. Can anyone tell me what I am doing wrong?
echo y | ssh root@::1 ufw reset
. In order to not use an unencrypted key for root access you could use an encrypted key and load it intossh-agent
. – kasperd Oct 25 '18 at 13:03