Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Upon the first time accessing a server, how can I force SSH to give me the RSA key and automatically store it if the user approves?

Presently it is offering me the ECDSA key. Because I already know the RSA key, I would prefer to see the RSA key presented at this point.

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.

share|improve this question

By removing the ECDSA algorithms from the HostKeyAlgorithms configuration variable.

ssh -o,,,,ssh-rsa,ssh-dss user@server

I've simply removed all the ECDSA algorithms from the default list.

You can, of course, put that in your .ssh/config for that machine:

Host: server
share|improve this answer
up vote 4 down vote accepted

Don't use RSA since ECDSA is the new default.

On the server do this: ssh-keygen -l -f /etc/ssh/ 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 for future use.

share|improve this answer
yeah but how about if I have an old application that needs RSA to maintain compatibility until there is a business decision to update to ecdsa? – enthusiasticgeek Dec 8 '14 at 23:02
@RobertSiemer only the original question poster can change the accepted answer. I am unable to do so. – enthusiasticgeek Feb 16 at 4:15
H2ONaCl: please change your accepted answer. This one does not do what you asked for. @enthusiasticgeek sorry, mixup. – Robert Siemer Feb 16 at 15:34

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

ssh -o HostKeyAlgorithms=ssh-rsa -o FingerprintHash=md5
share|improve this answer

Or, if you insist on having the RSA key approach, you can type ssh-keygen -t rsa on the server that you intend to SSH to.

That should generate RSA public and private keys under '~/.ssh/id_rsa'. Now all you need to do is to copy the public key under $HOME/.ssh/authorized_keys of all those machines from which you intend to ssh to the machine on which you generated your RSA keys.

And then sit back and relax!

share|improve this answer
You realize that the question was not about the client-side key but about the server key? – 0xC0000022L Jul 29 '15 at 22:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.