def _verifyfp_and_write_pubkey( (fingerprint_from_keyscan, hashed_pubkey) ): if fingerprint_from_AWS != fingerprint_from_keyscan: raise PublicKeyMismatch() print >>stderr, "The ssh public key on the server has fingerprint: %s" % (fingerprint_from_keyscan,) known_hosts_filepath = FilePath(os.path.expanduser('~')).child('.ssh').child('known_hosts') if not known_hosts_filepath.exists(): known_hosts_filepath.create() known_hosts = known_hosts_filepath.getContent().rstrip('\n') + '\n' new_known_hosts = known_hosts + hashed_pubkey known_hosts_filepath.setContent(new_known_hosts)