linuxbashsshrsa-key-fingerprint

SSH: Don't prompt for password in shell script


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?


Solution

  • ssh -o PasswordAuthentication=no user@hostname
    

    See man page of ssh_config for more details.