mpettis has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am writing a perl script to automate the spinning up of new instances in Amazon's EC2 cloud computing environment. The script will launch a new instance, do some admin on it via putty or ssh, and update some other config information (such as letting a proxy know that it can balance to the new server).

The problem is that when spinning up a new instance, the first interaction with putty or ssh requires you to confirm the fingerprints of the new server. I want to either skip this or tell the process prompt 'yes' to confirm and move on. Can I respond to this prompt in a perl script with a canned response, and if so, how?

Thanks, Matt
  • Comment on Replying to prompts in an automated script

Replies are listed 'Best First'.
Re: Replying to prompts in an automated script
by Corion (Patriarch) on Nov 23, 2008 at 20:52 UTC

    You want to set up passwordless keys for ssh. Automating entering the password is tedious, you will have to use Expect for that, or possibly use a Perl ssh client, like one of those that can be found through SSH. I recommend simply using passwordless keys.

    Ooops - I just realized that you want/need to accept the hosts fingerprints. I don't know any way other than Expect for that, except finding the fingerprint via other means, and storing it in the .ssh/known_hosts file yourself.

Re: Replying to prompts in an automated script
by oeuftete (Monk) on Nov 23, 2008 at 21:57 UTC

    This doesn't answer your question directly, but you can set an option with the OpenSSH client to skip that confirmation:

    $ ssh -o StrictHostKeyChecking=false remote_host

    I don't see immediately see an option in putty to do anything similar.

      This was perfect! Thanks!
Re: Replying to prompts in an automated script
by moritz (Cardinal) on Nov 23, 2008 at 22:01 UTC
Re: Replying to prompts in an automated script
by imrags (Monk) on Dec 10, 2008 at 11:32 UTC
    I have a similar problem....
    I've a windows machine, I have to telnet to about 180 machines...and run some commands, I want to automate the whole process... is there a way????

    Raghu