Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

It seems if I reboot that my ssh settings get wiped out.

I followed this tutorial to use ssh-add for the 2 other keys I need to get mapped.

Should I run this command in my bash config so it gets run each time?

share|improve this question
up vote 4 down vote accepted

Typically you'd have run ssh-keygen once to create a single ssh private key in ~/.ssh/id_rsa, paired with a single matching public key in ~/.ssh/ Then you'd install that one public key on each of the machines you need to ssh into. For instance, if it's a git repo on a Unix-like machine, you'd append your public key onto ~/.ssh/authorized_keys in the home directory of your account on that server.

The typical way ssh works is that you have a single private-public key pair that represents you, and you keep the private key private, but you install the public key into all the accounts on all the servers you need to access.

After that you could ssh into that machine, or clone a repo via git clone ssh://... or whatever, without being prompted for a password.

It sounds like rather than setting up ssh the typical way as I described above, you've instead generated two separate private-public key pairs, and they're not in your ~/.ssh/ folder, and so ssh isn't able to find them normally. It sounds like you've installed two separate public keys in other servers, one in each of the two git repo servers. It also sounds like you fired up ssh-agent and used ssh-add with arguments to tell it about some alternative location where it could find your private-public key pairs. So every time you log out or reboot, ssh-agent gets quit, and so you have to manually re-run ssh-agent and ssh-add each time.

This explanation of what's going on for you seems more likely to me than the idea that something is deleting ~/.ssh/ each time you reboot.

If I were you, I'd pick one of my two pairs of keys to be my identity, put that pair into ~/.ssh/, install the public key from that one pair onto both git repo servers, and not bother with ssh-agent and ssh-add at all.

Note, however, that there's one additional step you'd need to do, IF your username on the git repo servers is different than your username that you're using for you local account on your client machine. You'd need to create a ~/.ssh/config file to let ssh know what username to use when connecting to those other machines. The format is very simple:

User myGitRepo1Username
User myGitRepo2Username
share|improve this answer

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.