-
Notifications
You must be signed in to change notification settings - Fork 21
Setting up a Git server on Windows using Git for Windows and CopSSH
- CopSSH 3.1.4 (the latest free version)
- Git for Windows 1.7.10 (or later)
-
Install Git for Windows, selecting the "Run Git and included Unix tools from the Windows Command Prompt" when prompted. This option will install a
binfolder inProgram Files\gitthat will be placed into your path thus taking possibly taking precedence over other tools. -
Open up a bash prompt and run the following commands (these hard links are necessary, because CopSSH 3.0.3 appears to have an issue with symbolic links):
cd /bin ln -f ../libexec/git-core/git-upload-pack.exe git-upload-pack.exe ln -f git.exe git-receive-pack.exeIf you encounter problems with the above commands, try the following commands instead:
cd /bin ln -f ../mingw64/libexec/git-core/git-upload-pack.exe git-upload-pack.exe ln -f ../mingw64/bin/git.exe git-receive-pack.exeThese were found to work with Git for Windows 2.6.2 64-bit.
-
Install CopSSH.
-
Right-click "Computer" in the start menu and select "Manage". Select "Local Users and Groups" and proceed to create Windows users for all Git users. It is not required, but I recommend you give them passwords.
-
Activate all the Windows users under the CopSSH "01. Activate a User" option. Untick the "Create link to user's real home directory" option when doing so. Create new public and private keys if you don't have keys already.
-
If you already have private and public keys, copy them to the
...Program Files\ICW\home\{username}folder and call them{username}.keyand{username}.key.pub. Also copy the public key to...ICW\home\{username}\.ssh\and rename it toauthorized_keys. -
Create your Git repositories (
git init --bare ...), and make sure that you grant appropriate access rights to the repository folders for all users created in step 4. (If a user does not have write access to the repository folder, then an attempt to push to the repository will fail.) -
If you need remote access to the server, forward the SSH protocol (port 22, UDP and TCP) from your router to the server.
-
Reboot the server so the changes to the
Pathenvironment variable can take effect.
-
Copy the private key generated in step 5 (or the one you used in step 6) to the
.sshsubfolder in your user profile (typicallyC:\Users\Administrator\.ssh), and rename it toid_rsa. -
If you've generated the private key with a passphrase and you wish to remove it, run
ssh-keygen -pin a command prompt, and specify a blank new passphrase. If you don't remove the passphrase, you will be prompted for the password every time you interact with the server. -
If you're using TortoiseGit, remember to specify in the installer that you're using OpenSSH.
-
To check out a repository:
git clone {username}@{servername}:{repodriveletter}:/{repopath}
Once you have your sever setup and the users enabled through CopSSH, check out the official git docs for a more detailed explanation of actually setting up your repos on the server and then doing your initial commits from your workstation.