Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 938
multiholle Avatar asked Apr 16 '12 19:04

multiholle


People also ask

Why is SSH asking for a passphrase?

SSH uses private/public key pairs to protect your communication with the server. SSH passphrases protect your private key from being used by someone who doesn't know the passphrase. Without a passphrase, anyone who gains access to your computer has the potential to copy your private key.

Does SSH require password?

With an SSH Key set up, you can also safely log in to your server without any need for a password at all. The server will require the connecting computer to have the private key associated with the server's public key to connect.


1 Answers

ssh -o PasswordAuthentication=no user@hostname

See man page of ssh_config for more details.

like image 128
nosid Avatar answered Oct 05 '22 15:10

nosid