Super User is a question and answer site for computer enthusiasts and power users. 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

How can I supply a password on the command line or in a script rather than on an interactive prompt?

I need to copy files in a script and lets say public key is not copied yet to the target.

OS is any version of Unix, like HP-UX, Linux, Solaris etc.

One more thing: if I have to copy public key to a different machine, if say there are 100 users, then I need to copy the public key to 100 different users' $HOME/user/.ssh/authorizedkeys for a passwordless login.

Is there any way around this by modifying the root's authorized keys or known_hosts?

share|improve this question
Please user proper capitalization in your posts ("i" should be "I", "ftp" is "FTP", etc). Thanks. – slhck Jan 31 '13 at 11:26
up vote 4 down vote accepted

I'd say there are 2 options.. 1 you've already alluded to being the exchange of public keys.

The other is to investigate a small utility called 'expect'.

I'm sure this will do what you expect it to :)

See here for a good example :

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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