1

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!

0

1 Answer 1

3

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.

2
  • Beat me to it! +1 to you
    – gWaldo
    Sep 10, 2011 at 0:07
  • It's easier to use "ssh-copy-id myserver" to install the public key onto the server Sep 11, 2011 at 20:43

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