How to reinstall ssh key in Linux

Ssh key is very useful if you want to login quickly into applications such as when you want to clone or push from/to Github. Imagine if you set up this ssh key in plenty of services and you have to reinstall the operating system…what a nightmare!

Actually there’s a very easy way to setup your ssh key with zero pain.

First of all you have to backup in a pendrive your old ~/.ssh folder.

Now, when your os is ready, copy it into ~/

If you try now to add the key running $ ssh-add you are promped with something like this:

So, it’s now time to change the permissions. This gist list all the permissions.

The ones requires are these:

$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/id_rsa
$ chmod 644 ~/.ssh/

after this step let’s run the following command:

$ cd ~
$ ssh-add

You will be asked for the passphrase: enter your secret key and if everything is correctly you should see something like this:


This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.