On Server Box
Be sure to install it to a folder without space in its name. I used C:\SSH. Then just press next until it finishes.
2. install MSysGit
net user git userspassword /add
d. Goto C:\SSH\home\git\.ssh folder, create a file named authorized_keys. Open this file using wordpad.
f. (Re)Start SSH Server. You can either reboot your PC, or use below command line:
net stop opensshserver
net start opensshserver
g. Now it’s ready to test SSH connection. Invoke Putty.EXE, put localhost as host name, if you changed port in step c, don’t forget to change it here. Navigate to Connection/SSH/Auth node, press the “Browse” button to select the private file you generated and stored in step e, as shown below:
h. invoke a command window if you have not (where have you executed those “net xxx” commands?), and type
cd /d %USERPROFILE%
echo export HOME=/c/SSH/home/git > .bashrc
i. goto C:\SSH\home\git folder, open the .bashrc file (yes, the same name as in the above line). Insert below line to the first line: (AGAIN, THIS IS A UNIX FILE!)
export PATH=/cygdrive/c/Git/bin:/cygdrive/c/Git/libexec/git-core:$PATH
goto C:\SSH\home\git and make a folder named test.git. Right click the folder and select “Git Bash” from context menu. (What? You did not choose the explorer integration? Goto start menu, find Git|Git Bash, and use command line to goto this folder). Then input below lines:
$ git init –bare
Initialized empty Git repository in C:/SSH/home/git/test.git/
Now the server setup is DONE. You might need a cup of coffee of a cake to ease your nerve.
On Client PC
2. Test connection, using Putty. Change the host name and port as in your environment. Don’t forget the Connection | SSH | Auth node setting. Copy the private key file to client machine and point the file in this node. Then press “Open” button, you should find it similar to what you have experienced at step g above. But this time, after you logged in, you are actually logged in to another computer! After you logged in, type “git”, and see if you have the familiar git help screen before you. If you see
-bash: git: command not found
then please check if you have step i done correctly.
3. Opne a command window, type
Then use windows explorer to open this folder. create a files (id_rsa.pub) if they don’t exist.
4. Fire up PuttyGen.EXE again, load the private key you used at step 2. Paste the content of the text box to file id_ras.pub, and use menu “Conversions | Export OpenSSH key” to save to the folder you created at step 3, in name “id_rsa”. Now the folder %USERPROFILE”\.ssh should have at least 2 files: id_rsa and id_rsa.pub
ssh [email protected] “echo something”
input “yes” to accept the remote key. Then you should get an echo “something”
6. Now we are ready to clone the empty project we created at server
$ git clone ssh://git@tst/SSH/home/git/test.git
Initialized empty Git repository in D:/g/gt/test/.git/
warning: You appear to have cloned an empty repository.
Now you can make some change and push it back
Counting objects: 3, done.
Writing objects: 100% (3/3), 236 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://git@oti-tst/SSH/home/git/test.git
* [new branch] master -> master
Congratulations, you can clone and push back. It’s not as hard as it sounds, after all 😀