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

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/id_dsa.pub user@target.host

This prompts the user for user's password on target.host. 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 at 4:02

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.

    
Create keypairs for each user and give the user the public key. This has been around for quite a while. –  Nathan C Mar 21 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 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 at 22:19

1 Answer 1

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, deploy.pub), 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 ./deploy.pub user@target.host

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

cat deploy.pub .ssh/id_dsa.pub > both.pub
ssh-copy-id -i ./both.pub user@target.host
share|improve this answer
2  
What the what? Give an example, please, as it's not at all clear what you mean by this. –  EEAA Mar 21 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 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 at 17:21
    
The same that would prevent the user from using shared password.. –  neutrinus Mar 22 at 13:49

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