Amazon EC2: How to make SSH remember the server's key

1

I connect to my amazon EC2 Ubuntu 18.04 instant using SSH. Each time I input the SSH command, it asks me about trusting the key. And I answer yes. Next time it asks me again.

ssh -i "my_key.pem" ubuntu@mydomain.myregion.amazonaws.com The authenticity of host 'mydomain.myregion.amazonaws.com (xx.xx.xx.xx)' can't be established. ECDSA key fingerprint is SHA256:[some string]. Are you sure you want to continue connecting (yes/no)?

I checked the /home/.ssh/known_hosts.txt file. It repeatedly saves the file each time. Please note that I have previously missed up with this file. Then I uninstalled then reinstalled the SSH using these commands:

sudo apt-get purge openssh-server.
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install openssh-server 

How can I make SSH remember my server's key and stop repeatedly writing the key in the known_hosts.txt as this is going to make the file extremely huge.

user9371654

Posted 2019-03-31T16:04:32.863

Reputation: 647

No answers