Luke Puplett
Luke Puplett

Reputation: 45105

Git on Windows - How to authenticate with remote repo on Linux

Due to some serious problems with a Git repo on Windows over HTTP, we're moving our Git 'server' to Linux.

Assuming I have already the msysgit for Windows installed and Putty, how will I authenticate the SSH connection when I clone, pull and push?

Upvotes: 2

Views: 1185

Answers (3)

1615903
1615903

Reputation: 34732

This page has everything covered about using PuTTy for Git public key authentication. In short:

  • Generate keypair with puttygen
  • Put the public key in server
  • In your local computer, set GIT_SSH environment variable to point to plink.exe
  • Run putty pageant and load your private key there

Upvotes: 2

kostix
kostix

Reputation: 55443

I recommend working through this tutorial.

The caveat is that it talks about github, so the story of telling the server about your SSH key is different.

What's also different is how do you intend to manage your developers. The "problem" is that SSH operates with real remote (server-side, I mean) users, which have to have regular Unix system accounts.

This is okay if you have just a handful of developers. You then just need to add all of them to a special group (say, devel) and make sure you initialize your server-side bare repos using git init --bare --shared=group and make them group-writable and belonging to that group devel (this might also be helped out by creating all the repos under a directory which has its "group sticky bit" set and belongs to that group devel).

To distribute the public part of a developer's key to the server in such a setup you have to literally copy and paste that key part (from the developer's id_rsa.pub file, it's ASCII) to the file /home/developer/.ssh/authorized_keys file. If that file does not exist, create it. If the key was generated on a machine with OpenSSH client installed, you can transfer the key using the ssh-copy-id program, in one step.

This might become messy, so you might consider implementing a solution which virtualizes Git users (like github does). There are plenty to choose from:

  • gitolite — supposedly the most popular solution. No frills, is administered using a specialized admin Git repo holding the developers' public keys and a configuration file describing the repos and permissions on them. Plain Perl, installable as a package on most sensible distros.
  • gitlab — a turn-key all-in-one solution. Written in Ruby, so you might face maintenance nightmares.
  • gitblit — another all-in-one solution, written in pure Java (note that it does not call out to vanilla Git and uses a pure Java Git layer — JGit).

Upvotes: 0

Suki
Suki

Reputation: 46

In case of SSH:

  • on the server, you'll need to allow authentication with public and private keys, you can google how to do it, for example http://shapeshed.com/setting_up_git_for_multiple_developers/
  • on the client, just put your private key into .ssh folder in your windows home, for example C:\Users\Name\.ssh, much like on unixes.

You can still use HTTP, it will either (1) always ask for username and password or (2) you can also put username and password into the URL: https://username:[email protected]/...

Upvotes: 3

Related Questions