16

Can you use the same ssh key for different version control hosting services?

And if you can, what are the pros and cons?

Scenario: I have ssh keys that I am using on my computer, can I and should I use the same ssh keys with gitlab/gitbucket on the same computer?

YulePale
  • 6,688
  • 16
  • 46
  • 95
  • 1
    Of course you *can*, the services don't cross-check against each other to tell if a key is in use elsewhere, but as VonC points out, you probably shouldn't. – user229044 May 24 '19 at 05:04

1 Answers1

28

No, it is not advisable: a private key should remain used for only one service, that way you can revoke/change it just for that service.

What you can do is set up a ~/.ssh/config file in which you can associate the right private key with the right host, as explained here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hey kindly check out https://stackoverflow.com/questions/56287059/how-to-set-up-an-ssh-config-file-for-beginners?noredirect=1#comment99187049_56287059 – YulePale May 24 '19 at 06:47