Skip to content

Edoardo Vignati

– Always looking for something awesome –

Menu
  • About me
  • Studies
  • Publications
  • Skills
  • Portfolio
  • Projects
  • Career
  • Blog
  • Travels  
Menu

How to reinstall ssh key in Linux

Posted on 29/07/202011/03/2023 by Edoardo

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/id_rsa.pub

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:

If you are doing this in the Linux Subsystem of Windows you may encounter the following error:

"Could not open a connection to your authentication agent."

In this case, run this in the terminal:

$ eval $(ssh-agent)
$ ssh-add

Finally, if you have to put the public key to a server or a vps to login, you can launch this command:

$ ssh-copy-id [email protected]

and then when you try to login the password is no longer required

Cheers


Buy Me A Coffee


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

Leave a Reply Cancel 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.

  1. Edoardo on [SOLVED] XMLHttpRequest error in Flutter web is a CORS error06/01/2023
  2. Fabi on [SOLVED] XMLHttpRequest error in Flutter web is a CORS error20/12/2022
  3. Edoardo on How to install hplip on Ubuntu28/11/2022
  4. Alex K on How to install hplip on Ubuntu28/11/2022

© 2023 Edoardo Vignati | Powered by Minimalist Blog WordPress Theme