python - ssh key of newly created ec2 instance using boto -


i using boto connect ec2 , launch instance. after creating instance, need ssh it. need public ssh key of server add known hosts file. how key using boto? not want bypass key verification. have used boto command shell, looking @ source, looks boto uses paramiko , bypasses checking ssh key. can please help?

# check see if specified keypair exists. # if invalidkeypair.notfound error ec2, # means doesn't exist , need create it. try:     key = ec2.get_all_key_pairs(keynames=[key_name])[0] except ec2.responseerror, e:     if e.code == 'invalidkeypair.notfound':         print 'creating keypair: %s' % key_name         # create ssh key use when logging instances.         key = ec2.create_key_pair(key_name)          # aws store public key private key         # generated , returned , needs stored locally.         # save method chmod file protect         # private key.         key.save(key_dir)     else:         raise 

Comments