I am trying to SSH into my fresh Ubuntu 12.04 server. At the client I have deleted known_hosts. SSH to the host for the first time has it offering me an ECDSA key to verify. The problem is I know how to get the RSA key and verify it but I don't know how to get the ECDSA key.

How can I force SSH to prompt with the RSA key and store it if I approve?

I have tried:

ssh -o RSAAuthentication=yes user@server

Unfortunately this gives me an ECDSA key and the Are you sure you want to continue connecting (yes/no)? message.

  • Note option RSAAuthentication (and the related RhostsRSAAuthentication also) was about authenticating the client, not the host, and only in SSHv1, which was broken and obsolete last century. OpenSSH 7.5 in 2017 (well after this Q was asked) removed SSHv1 entirely and disabled related options. The option for PKC client auth in SSHv2 is PubkeyAuthentication. The server always uses PKC auth, so there is no option to enable it, only to tailor it with HostKeyAlgorithms as correctly answered. Commented Jun 22, 2018 at 2:13

3 Answers 3


You can also tell the server what algorithm to use from the client (for example if you already have the rsa fingerprint written down and are physically far from the server)

  ssh -oHostKeyAlgorithms='ssh-rsa' host

Don't use RSA since ECDSA is the new default. Newer things are sometimes better. Default things are often better for the convenience of most people. A new thing that is a default thing is very probably better for most people.

On the server do this:

ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub

and record that number.

On the client you can SSH to the host and if and when you see that same number, you can answer the prompt

Are you sure you want to continue connecting (yes/no)?

affirmatively. Then the ECDSA key will get recorded on the client in the known_hosts file at the default location so that future use of ssh will not require you to acknowledge the identity of the remote host.


If you will ever stop using that remote host, perhaps because it is a cloud server that you have deleted, then delete the record from the known_hosts file via:

ssh-keygen -R

or something like that.

  • Sometimes this isn't possible, in my case a java dev is using an old SFTP library that only supports known hosts files in RSA format and won't accept ECDSA (who knew)
    – Rumbles
    Commented Jun 5, 2017 at 14:36

Yes, OK switch to ECDSA soon, but in the meantime try this:

ssh -oHostKeyAlgorithms=ssh-rsa -o FingerprintHash=md5 [email protected]
  • 2
    Can you explain how this is different from the top-voted answer? How is your answer unique?
    – schroeder
    Commented Dec 18, 2015 at 3:33
  • 2
    Sure. A recent version of sshd switched from defaulting to RSA to defaulting ECDSA. It also appears to have updated the fingerprint hashing algorithm from MD5 to something more modern. I launch a lot of EC2 instances, and have written a script that runs on instance launch which tags the instance with the RSA host key's MD5 fingerprint. Until I update my tagging script, I have to specify both RSA and MD5 to verify my host keys. I'm guessing the OP might be having a similar problem.
    – bonkydog
    Commented Dec 19, 2015 at 21:54
  • 1
    You need to edit your answer to include these details
    – schroeder
    Commented Dec 19, 2015 at 22:04
  • @bonkydog is 100% correct - this was my issue as well. Commented Jul 22, 2016 at 18:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .