Bash piping answer in Ubuntu

In a bash script, I want to know know how to pipe in answers like for example:

ssh -l username -i /home/ubuntu/.ssh/id host.com < yes

The ssh connection would ask if I would like to continue the connection and I want to pipe in the answer yes automatically and enter me in, but my script "< yes" doesn't seem to work. Does anyone know how to properly type and pipe the response "yes" in bash under Ubuntu?


You usually are only asked if you want to connect when ssh is performing host key checking. Instead of trying to disable by using expect or a pipe, perhaps you could just disable it in your ssh configuration.

Add StrictHostKeyChecking no to your ~/.ssh/config, and ssh will no longer ask you if you want to connect, it will just connect.


Use ssh -o "StrictHostKeyChecking no" -l username -i /home/ubuntu/.ssh/id host.com to avoid the question altogether.