5

I have added my ssh key to many servers as authorized key, But because of some reason, I had formatted my laptop.

Now is there any way to assign my previous ssh key to my laptop so that I can login seamlessly without any issue to all servers.

I have saved my ~/.ssh/id_rsa.pub file before laptop format and I copied this key in the same file after format but it is not working and I am not able to login.

4
  • 6
    You would need the private key file, i.e. id_rsa (without the .pub extension) on you local machine. If you don't have that anymore, then it won't work.
    – PerlDuck
    Feb 5, 2018 at 11:00
  • Do you want to say that I should copy id_rsa and id_rsa.pub both file before format and copy the same after os reinstalling ?
    – RjV
    Feb 5, 2018 at 11:10
  • 7
    As PerlDuck said, you need the private key file. If that one is lost, you have to remove your key from the authorized lists of all these servers and then create a new key pair and add that instead. To clarify, the public key (id_rsa.pub) is the one you give to other people (or store on servers) so that they know how to recognize you. The private key (id_rsa) must stay secret and exclusively in your control, as that is what you need to prove you are yourself. You can regenerate a public key from a private key, but not the other way round.
    – Byte Commander
    Feb 5, 2018 at 11:11
  • Thanks PerlDuck and @ByteCommander for detail describe ....I got it
    – RjV
    Feb 5, 2018 at 11:35

1 Answer 1

0

There are two components to ssh keys.. the Private key (which is most likely id_rsa) which acts like a regular key. and the Public counter part which acts like a regular lock.

The id_rsa.pub file is the public key and without the private key is useless.

You can add the public key onto as many machines/user account in their .ssh/authroized_keys file. And that will allow them to be access using the private key.

Its perfectly safe to distribute your public key in this way.. However as with regular keys making copies of your private key shouldn't be done lightly. Which is why mastering ssh-agent is a good idea as that allows you to keep your private keys on your local box but use them remotely.

This guide will help you understand the SSH authentication.. http://unixwiz.net/techtips/ssh-agent-forwarding.html

You must log in to answer this question.

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