Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

On Linux when using dsa keys I establish passwordless login with the command

ssh-copy-id -i .ssh/

This prompts the user for user's password on My script knows the password and the user shall not be bothered, how can I do this?

share|improve this question

marked as duplicate by Jenny D, Zoredache, Tim Brigham, Katherine Villyard, Ward Mar 22 '14 at 4:02

This question was marked as an exact duplicate of an existing question.

Create keypairs for each user and give the user the public key. This has been around for quite a while. – Nathan C Mar 21 '14 at 12:46
If you must do this, then you probably would want to look at using the expect based examples from the linked questions, to provide the passwrd. – Zoredache Mar 21 '14 at 17:25
Wait, you are using a key pair and still being prompted for a password? Are you sure it's not the key passphrase what it's being requested? – dawud Mar 21 '14 at 22:19

Just generate a pair of keys and provide it with your script. This would be the preshared key to upload a real key.

EDIT: Generate a separate keys for keydeployment: (deploy,, ship them with your script. This mean that from machine with script (so with those keys) you just can login without a password:

ssh -i ./

Then use this key to deploy user key on the target:

cat .ssh/ >
ssh-copy-id -i ./
share|improve this answer
What the what? Give an example, please, as it's not at all clear what you mean by this. – EEAA Mar 21 '14 at 12:43
You add a known private key to your software with whole purpose and restriction of uploading a new public key to the user. With this you don't need a password for the ssh-copy-id. – lhw Mar 21 '14 at 13:27
I assume you would have some kind of restrictions in place to prevent users from using this shared key from being abused? Please elaborate. What would prevent the user from simply using the private key you are suggesting that you would provide. – Zoredache Mar 21 '14 at 17:21
The same that would prevent the user from using shared password.. – neutrinus Mar 22 '14 at 13:49

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