Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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'.

http://linux.die.net/man/1/expect

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

See here for a good example : http://stackoverflow.com/questions/4780893/use-expect-in-bash-script-to-provide-password-to-ssh-command

share|improve this answer

Your Answer

 
discard

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.