SSH from one EC2 to another

On Server A

  1. ssh-keygen -t rsa
  2. Copy the contents of id_rsa.pub to ~/.ssh/authorized_keys of Server B.
  3. ssh -i ~/.ssh/id_rsa ec2-user@private_ip_of_server_B

This is working fine with RSA key, but when I generate key using ed25519 then i get “Permission denied (publickey,gssapi-keyex,gssapi-with-mic)” error.
Is there something that I’am missing? Can someone help me with this.

What are the steps you are taking for the ed25519 key? Try using ssh-copy-id to send the key to the server. Also check /etc/ssh/sshd_config and the HostKeyAlgorithms line includes ed25519.