php - Error out instead of asking for passphrase with SSH -


i'm writing script uses rsync, , want error out if ssh key has password, telling user use non-password protected key instead (as script runs in background).

however, none of flags i've tried ssh this, , i've found nothing in man pages.

what's best way disable passphrase prompt ssh?

you can using batchmode option. cause ssh avoid may cause script hang, such password/passphrase prompts.

this example taken directly similar question asked @ http://www.unix.com/programming/184775-test-ssh-but-do-not-return-password-prompt.html

if ssh -o batchmode=yes "$hostname" true 2>/dev/null;     echo "it works" else     echo "it's broken." if 

here's example rsync:

rsync -e "ssh -o batchmode=yes -i /var/www/.ssh/id_rsa" /path/to/test/file.txt remotehost:/path/to/test/file.txt 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -