Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
How to automate SSH login with password?

Is there a way to call ssh in a bash script and automatically feed it the password for the account?

e.g if i type

ssh owen@myserver.com /settings

it prompts me for a password. I want to avoid that!

share|improve this question

marked as duplicate by Shane Madden, Ben Pilbrow, Sven, MikeyB, Murali Suriar Sep 10 '11 at 0:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

You can use passwordless authentication with SSH using SSH Keys.

On your client machine, run

ssh-keygen -t rsa

This will generate 2 files ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub, these are your public and private authentication keys.

Copy ~/.ssh/id_rsa.pub from your client machine on to your target as ~/.ssh/authorized_keys2.

You should now be able to access your server without needing a password.

share|improve this answer
Beat me to it! +1 to you –  gWaldo Sep 10 '11 at 0:07
It's easier to use "ssh-copy-id myserver" to install the public key onto the server –  Giovanni Bajo Sep 11 '11 at 20:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.