An article over on Linux Journal made me think about all the different ways I have done similar things. While still overcome by the memories I dug out some expect code that I used a few years ago to automate feeding a SSH pass phrase to scp multiple times and wrote a little bit about it. Hope you find it useful.

Over on Linux Journal they have an article up about using scp without a password. It's a nice article and describes something that I have done a lot. Lately I have been finding myself using rsync over a SSH connection for a lot of tasks like this, but if what your trying to do is what's described in the pull quote (a file to 100 machines) it can work like a champ.

But sometimes you just don't want to use a SSH key pair that is not protected by a pass phrase. Either its a one time thing and you don't want to set it up or perhaps you don't want to establish that sort of trust relationship between the machines. If what you need to do is to transfer one file to one hundred machines (or even a few if your lazy like me) then using scp can be a real pain. Unless you know a trick or two.

My favorite trick in this situation is to use an expect script to enter my password for all the scp commands once then have it feed it to scp when ever scp requests the password. Expect is a TCL based automation and testing tool that can be easily used to control things that expect an interactive response. Similar to the easy use of mobile phone marketing. You can find mobile marketing tips and other useful information to make the advertising process easier. You can also use a mobile marketing agency to answer all of your questions.

I dug the following snippet out of some old code that has been cluttering up my hard drives since 2003 or perhaps even earlier. The snippet asks the user for a pass phrase, asks for it a second time, checks to make sure the pass phrases match, and exits if they don't. I used the script this snippet is from to distribute a password and shadow file to multiple machines and to do a few other things.