0

Sometimes ago I got this issue and tried to follow the instruction for my PC.

Cannot push to git repository on bitbucket

It worked, and I already have one SSH key with bitbucket.

Now I have another machine with a new hard drive, so I need to setup git again. I thought I could just add the global config:

git config --global user.name '<myname>'
git config --global user.email '<myemail>'

But it doesn't work. So it seems like I need to go through the steps mentioned in the above link all over again.

Is there a better way to setup that SSH access from an existing account (jsut from a differ machine) rather than following such a long and mundane steps.

Community
  • 1
  • 1
artm
  • 17,291
  • 6
  • 38
  • 54

1 Answers1

2

Now I have another machine with a new hard drive, so I need to setup git again. I thought I could just add the global config:

git config --global user.name '<myname>'
git config --global user.email '<myemail>'

But it doesn't work.

That's right. It would be a shame if somebody else could just run those commands and gain access to your account!

Those settings are actually irrelevant to Git authentication. They just determine how commits are recorded.

So it seems like I need to go through the steps mentioned in the above link all over again.

That's what I'd recommend: Generate a keypair for your new machine and add it to your Bitbucket account.

(Technically you could avoid creating a new keypair if you copy your existing keypair from your old machine onto your new one, but that's trickier than it sounds. OpenSSH is very picky about file permissions. I always create new keypairs per machine.)

Finally, you could access your repositories via HTTPS instead of SSH. That way you'd have to enter your Bitbucket user name and password to gain access. Though if you've enabled two-factor authentication that gets trickier…

Community
  • 1
  • 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Question: What are the problems with using the same private key? – dubes Nov 17 '16 at 12:42
  • 1
    @dubes, (a) keypair security should be taken seriously. If anybody else get a copy of the pair (public and private, both of which you'd need to copy to your new machine) they gain full access to your repositories. I believe that copying keypairs encourages the user to think about said security more casually. (b) Having different keys lets activity be linked to a particular machine. You can easily remove a key for an old machine without affecting access for new ones. (c) Generating a new keypair is no more work than copying one, and pasting it into Bitbucket takes 30 seconds. Why _not_ do it? – ChrisGPT was on strike Nov 17 '16 at 12:48
  • cool thanks, that to confirm I really need to go through those steps again. I though that if I configure the username and email address, there could be some mechanism to query for the password and remember it for that machine.. But seems like not the way how it works. And that OpenSSH steps (quoting from the mentioned question - doesn't look simple - even `FOR THE LAZY` ;) – artm Nov 17 '16 at 20:57
  • @artm, if you're on Windows it's a bit more of a pain. But on Linux or OSX generating a new keypair basically boils down to running `ssh-keygen` on the command line. – ChrisGPT was on strike Nov 17 '16 at 21:00