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?

2 Answers 2

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.

3
  • 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 Jun 12, 2019 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.
    – oxr463
    Jun 12, 2019 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 * Jun 13, 2019 at 7:01
0

Adding

Host *
  IdentityFile ~/.ssh/id_rsa

resolved the issue

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.