Turn: setting up a msysgit server with copssh on Windows

Source: Internet
Author: User

Http://www.timdavis.com.au/git/setting-up-a-msysgit-server-with-copssh-on-windows/

OK-Let me start this post by saying this is absolutely not for the faint hearted. this was a serious-and I re-emphasize this-serious pain in the arse to the do. having almost no experience in Linux before-copssh emulates the Linux environment through cygwin-let me tell you that this process was not easy. if you are an expert and thought-"pfftt, this process was easy "-I will reserve my language and ask you to kindly move along for those of you with no clue at all (Ala me)-then this post is for you.

firstly, full credit goes to the fantastic team at msysgit-these guys rock for porting git to Windows-Git is an unreal DVCs and so I cant thank them enough for making this all possible. secondly, full credit goes out to the guys at stackoverflow-Unreal website and lots of fantastic users that have helped answer questions which have allowed the making of this guide possible. please feel fre E to ask me questions, but I stronugly recommend stackoverflow as your first port-of-call as I may take longer in getting back to you than they will. also, this instruction guide is how I have set it up -if you start changing things-May the force be with you!

Finally, if this process worked for you-please leave a comment telling me (and everyone else) that it works and share this article around. it took me quite a bit of time to figure all this out on Windows-not to mention the time to type up this Guide-so I wowould appreciate a link back

Pre-Setup

    1. Download copssh [SourceForge link]
    2. Download msysgit
    3. Download tortisegit
    4. Download putty Installer
    5. * Optional download git Install guide (this guide as a printable PDF)

Step 1-installing copssh

    1. You 've got copssh-Now go on and install it.
    2. Install copssh into the c: \ SSH directory
    3. Write down the svccopssh password-you will probably never need it-but just in case.
    4. It will install and create a bunch of directories-(Aside: I have found that you don't need to create a password on your Windows User Account-it's not necessary if you use the settings I have later)
    5. GotoStart-> Programs-> copssh-> activate a user
    6. You can only activate existing users on Windows-so you can chooseYour Own AccountOrAdministrator(Or indeed another account but I 've used the primary)
    7. Uncheck the option-Create keys for Public Key Authentication-We will do this ourselves.
    8. Finish the installation process.

Step 2-setup copssh

  1. Open Windows Explorer-goC: \ SSH \ etcAnd open both yourSsh_configAndSshd_configIn WordPad (ASIDE: note-one has a "D" and one doesn't-it's an important difference)
  2. Ssh_config-Delete the # (pound) Key next to "Port" and change this to something like 4837 (or whatever port you want to use)
  3. Sshd_config-Delete the # (pound) Key next to "Port" and change this the same as that inSsh_config-I. e. in this example 4837
  4. Sshd_config-Delete the # (pound) Key nextMaxauthtriesAnd make this 2
  5. Sshd_config-Delete the # (pound) Key nextRsaauthentication& Also next toPubkeyauthentication
  6. Sshd_config-Delete the # (pound) Key nextPasswordauthenticationAnd make thisNo.
  7. Save all the changesSsh_configAndSshd_config.
  8.  Open your router IP address (or however you access your router) and open the port you are using-I. e. in this example 4837(ASIDE: If you don't know it-c: \ cmd-> ipconfig/all-will tell you)
  9. Save these port changes in your router(& Restart your router if needed)
  10. OpenWindows Firewall with Advanced Security SettingsAnd create a rule which allows the port you set in bothSsh_configAndSshd_config-In this case 4837(Also do this in your firewall if your firewall requires it-maybe/maybe not)
  11. Restart your PC.

Step 3-installing putty

  1. Welcome back after the restart-now open the putty installer you downloaded.
  2. Install everything
  3. Navigate to the putty installed directory (usuallyC: \ Program Files \ putty)
  4. OpenPuttygen.exe
  5. Enter inNumber of BITs in a generated key4096
  6. Move your mouse around und randomly as your ucted until finished-Don't closePuttygen!
  7. Open Windows Explorer and navigateC: \ SSH \ home \ <user> \. Ssh \-I. e in our caseC: \ SSH \ home \ Administrator \. Ssh \ (Aside: If. SSH doesn' t exist-you can only create it via a cmd.exe prompt-open cmd.exe and enter cd c: \ SSH \ home \ <user> \ then enter mkdir. SSH)
  8. Create a new file calledAuthorized_keys (Aside: If it's not there-Right click-New Text Document-delete everything (including the *. txt)-name the file authorized_keys)
  9. OpenPuttygenAnd copy/pastePublic Key for pasting into OpenSSH authorized_keys filesCode.
  10.  Still inPuttygen-Save the private keyPrivate_key.ppkIn the sameC: \ SSH \ home \ <user> \. Ssh \-I. e. I. e in our caseC: \ SSH \ home \ Administrator \. Ssh \ private_key.ppk
  11. You shoshould now have 2 files in this directory-Authorized_keysAndPrivate_key.ppk
  12. To test our connection-load upPutty.exeFrom the sameC: \ Program Files \ putty
  13. Enter yourIP addressAndPortInSessionWindow (ASIDE: If you don't know your IP-c: \ cmd-> ipconfig/all-will tell you)
  14. Click onSSHIn the left hand menu and select-Auth-Then navigate to your private keyC: \ SSH \ home \ <user> \. Ssh \ private_key.ppk
  15. HitOpenAnd a terminal will open asking youEnter Login Name:-Enter your <user>-I. e. In our caseAdministrator
  16. You may get a message aboutAccept Public Key-Type Yes & if you get logged in great!

Step 4-installing msysgit

  1. OpenMsysgitInstaller package.
  2. Ensure itsC: \ Program Files \ git(X32 bit) orC: \ Program Files (x86) \ git (X64 bit)
  3. SetUse git bash only (Aside: I wanted to only use git bash console but if you want to run git from the Windows Command Prompt then you have to select this option-I wocould recommend only options 1 & 2 unless you really know what you are doing)
  4. SelectUse (tortoise) plinkAvailableC: \ Program Files \ tortoisesvn \ bin \ tortoiseplink.exe. if it's not available in the installer then set the variable in the Windows environment to git_ssh =/path/to/tortoiseplink.exe. (aside: I set this as using just putty plink.exe as opposed to tortoiseplink.exe-wocould recommend settings this instead to c: \ Program Files \ putty \ plink.exe but it's up to you)
  5. Let it install and have a laugh in the meantime.
  6. Once it's installed-You now have 2 windows which I will name 1.Git bash (Right click mouse on a file/folder in Explorer)And 2.Start-> Programs-> copssh->Start a Unix bash shell-Unix bash.
  7. Finally, Goto your Git-core folder in the GIT installed directory-C: \ Program Files \ git \ libexec \ Git-core(X32 bit) orC: \ Program Files (x86) \ git \ libexec \ Git-core (X64 bit)-and copy the filesGit.exe, git-receive-pack.exe, git-upload-archive.exeAndGit-upload-pack.exeAnd paste these into yourC: \ SSH \ bin.

Step 5-Modify the user environment

  1. The problem with copssh is that it sets its $ home environment toC: \ Users \ <Name>OrC: \ Documents ents and Settings \ <user>Variable-and git looksAuthorized_keysIn this folder. Of course, we don't want this-we setup our server environment inC: \ SSH \ home \ <user> \. SSHAnd so we want git to look for keys in there.
  2. Open Windows Explorer-go into C: \ SSH \ home \ <user> \And open. BashrcFile Using a text editor(Aside: Be sure not to attempt to format this file as it has UNIX encodings not dos encodings-I. e. just open it in a text editor and don't use another viewer unless you want encoding errors-you don't need to read the text in this file if you are following these instructions to tee .)
  3. Put the cursor at the beginning of. BashrcFile and use Ctrl + F to find the following text-Bashrc File. # User dependent. bashrc file #
  4. After the text. Bashrc file #(After the pound with a space)-paste in-Export Home =/C/ssh/home/<user> -I. e. In our case Export Home =/C/ssh/home/Administrator
  5. Ensure there is a "space" before and after this paste in-I. e.. bashrc file # <space> Export Home =/C/ssh/home/Administrator <space> shell options #
  6. Save this file and close it.
  7. Copy this file and navigate to your windows assigned home directory(Aside: git will still be looking for your path in this directory so we need to set to refer to ourC: \ SSH \ home \ <user> \ directory instead)
  8. Paste this in yourC: \ Users \ <Name>OrC: \ Documents ents and Settings \ <user>-So it now hasC: \ Users \ <Name> \. bashrcFor example.
  9. Open bothGit bash (Right click mouse in Explorer)AndStart-> Programs-> copssh->Start a Unix bash shell-Unix bashShell
  10. TypeEcho $ home-Into both-They shoshould both spit out-/C/ssh/home/<user>
  11. If one does not-you need to set it-Export Home =/C/ssh/home/<user>

Step 6-install tortisegit

    1. Install tortisegit per the standard installer usingPlink.exe(Aside: This shoshould be the same as that setting at Step 4.4)
    2. Once the install has completed, Open Windows Explorer.
    3. Right click on anything and gotoTortisegit-> Settings
    4. SelectGeneralAnd ensure the msysgit path is setingC: \ Program Files \ git \ bin (X32) orC: \ Program Files (x86) \ git \ bin(X64)
    5. SelectNetworkAnd ensure that this is set to the samePlink.exePath that we set in step 6.1.
    6. SelectSaveThenOK.

Step 7-using git and plink

  1. NavigateC: \ SSH \ home \ <user>And create a new directory called <MyApp>. Git-I. e.C: \ SSH \ home \ Administrator \ MyApp. Git
  2. Right click on this new directory and selectGit bash
  3. When the window loads enterGit-bare init
  4. You'll now see(Bare: Master)Appear and can close the window.
  5. navigate to C: \ Program Files \ putty and open pageant.exe - A small icon will appear in your system tray at bottom right hand corner of your screen (a PC with a hat on it) -open this and add your key from C: \ SSH \ home \ Administrator \. SSH \ private_key.ppk (aside: I recommend adding pageant.exe to your start-> Startup Folder so this will load each time you start your PC. to do this, Goto start-> putty and right click on pageant.exe. then change the target path to c: \ \ pageant.exe dir: \ \ private_key.ppk. then drag pageant.exe to your Startup Folder-this will then load both pageant.exe and your private key each time the system loads. refer here if confused .)
  6. Now it's time to clone this repository to our local development environment and finally start using git
  7. Navigate to where you want to have your local repository-in my caseD: \ git \
  8. Right click inside this directory and hitGit clone
  9. Enter your URL as SSH: // <user >@< ip_address >:< port number>/ssh/home/<user>/<git directory>-I. e. in our caseSSH: // administrator@127.0.0.1: 4837/ssh/home/Administrator/MyApp. Git
  10. The directory shoshould have the correct path-I. e. In my caseD: \ git \ MyApp
  11. There is no needLoad putty keyAs we have already done this usingPageantIn step 7.5.
  12. Hit OK and with a bit of luck (a lot of luck) you will get a successful clone.

 

Step 8-the real test

 

    1. Cloning is one thing-the real test is pushing a new commit.
    2. Go to your newly cloned directory-D: \ git \ MyApp
    3. AddNew text document.txt
    4. Go back to justD: \ git \-> right click on the folder-> Git commit-> "master "...
    5. Enter a new commit message "test" & tick the checkboxNot versionedCOMMIT on the fileNew text document.txt.
    6. HitOK& Then hitPush.
    7. EnsureLocal: MasterToRemote: Master(For this test) &Remote: Origin
    8. HitOKAnd you shoshould get below

Counting objects: 1, done.
Compressing objects: 100% (1/1)
Writing objects: 100% (1/1)
Writing objects: 100% (1/1), 244 bytes, done.
Total 1 (delta 0), reused 0 (delta 0)
To SSH: // administrator@127.0.0.1: 4837/ssh/home/Administrator/MyApp. Git
0526eba .. a1bf4a4 master-> master

If yes (get a beer), if no (seeProblem GuideAnd get ready for tears, profane language and keyboard bashing)

Problem Guide

Copssh

    1. I don't understand how to install copssh-can't you add some pictures?No, but this guy can.
    2. I want to add another directory instead of installing my git repo in the home account?OK, see here which must be doneUNIX bash.
    3. When I check services. MSC-I can see that the service has stopped-what can I do?You can setup a dependent copssh service if you are brave.(Tip: If you don't know what you are doing, don't stop the service ever-when you make changes to c: \ SSH \ etc \ directory restart your PC instead)

Putty

    1. Can I create keys with less encryption than 4096 from step 3.5?You can never have enough encryption so no(Well at least it's my opinion !)
    2. I cant connect via putty?You may have to regenerate your keysPuttygen.exeAnd put them back into your/. Ssh/authorized_keysFile perStep 3 instructionsAbove.

Git

    1. I keep getting "Fatal: the remote end hung up unexpectedly "?Open a git bash window and typeEcho $ home-Ensure it is set to/C/ssh/home/<user>/. If it is not-enterExport Home =/C/ssh/home/<user>
    2. I get "Fatal: Connection refused "?Check that you have correctly opened the port you have set on the service per step 1.
    3. I get "Fatal: no authorized methods accepted "?You will have to regenerate your keysPuttygen.exeAnd follow steps per 3.
    4. I get "Git-upload-Pack: Command not found "?You must ensure that you have completed step 4.7 and copied the relevant files into yourC: \ SSH \ binDirectory.


    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.