Skip to content

How to connect to AWS EC2 instance with *.pem file #423

Answered by ronf
compfaculty asked this question in Q&A
Discussion options

You must be logged in to vote

This error is about the host key, not the client keys. To get rid of the error, you'll either need to collect the public keys associated with all of the hosts you are trying to connect to and add them to a "known_hosts" file, or you'll need to disable host key validation by passing in known_hosts=None, but that leaves you open to a man-in-the-middle attack.

You can collect the host key from a system and using a call like:

    host_key = await asyncssh.get_server_host_key(host)

Once you have the server's key, you'd ideally want to verify that it is one you should trust, and then you could add it to the known_hosts file using something like:

    host_key.append_public_key('~/.ssh/known_hosts')

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by compfaculty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants