Lucas
Lucas

Reputation: 13

How can I use an old key in the file id_rsa.pub in a new Linux installation?

I have the old key in the file ~/.ssh/id_rsa.pub. I had to format the computer, how to restore this key to gain access to the servers again?

Upvotes: 1

Views: 5823

Answers (1)

soerface
soerface

Reputation: 6833

I suppose you mean with "the old key in the file id_rsa.pub" your client ("computer") and that you lost it during formatting the client. This public key should already persist on your server. To be able to authenticate to your server, you need the matching private key (~/.ssh/id_rsa). If you have it, just copy it back to that location on your new system.

If you lost it during formatting and have no backup, the only way to regain access is to generate a new pair (ssh-keygen) and copy the public key to your server (for example via ssh-copy-id) while authenticating via password, if you have not disabled that. I would also suggest removing the old public key from the server in that case.

Upvotes: 2

Related Questions