0

I have moved my private key to a new PC. Permissions are correct (0600) However, ssh user@server doesn't use the migrated key I tried creating the config file for that host, but still nothing

The key works if referenced directly via ssh -i ~/.ssh/id_rsa user@server

Can't seem to find any useful info on migrating private keys between computers (except: just copy)

What am I doing wrong?

0

In your ~/.ssh/config on your old computer, you should have a line similar to the one below,

Host server
  IdentityFile ~/.ssh/id_rsa

This is what tells ssh to use the key without having to specify it manually.

| improve this answer | |
  • Done that, didn't work. In the end, adding Host * was the solution. But the computer where I created the key didn't have the config file – Tomislav Plečko Jun 12 '19 at 13:19
  • That's because the asterisk means for any host. So if you were connecting to github.com it would be Host github.com. – rage Jun 12 '19 at 21:57
  • The problem was that ssh didn't use my key for any connections (computer where I generated the key doesn't have the config file, but ssh uses the only available key. On the new pc, I had to use Host * – Tomislav Plečko Jun 13 '19 at 7:01
0

Adding

Host *
  IdentityFile ~/.ssh/id_rsa

resolved the issue

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.