I'm using ssh and have a passwordless ssh setup for my system. Using ssh in a script works fine, but if the user specifies a host that don't has a passwordless ssh setup the script prompts for a password and hangs.
How could I avoid the password prompt and return an error if passwordless ssh is not setup for the host?
ssh -o PasswordAuthentication=no user@hostname
See man page of ssh_config
for more details.