How to Set Up a Git Server with SSH on Windows

Setting up a git server with SSH on my LAN can be confusing. So many suggestions exist that you may get lost in it. This article will help you install Cygwin. This includes installing Cygwin on your Windows machine. First, install...
Part 1 of 2:

Install and Set Up Cygwin

  1. How to Set Up a Git Server with SSH on Windows Picture 1How to Set Up a Git Server with SSH on Windows Picture 1
    First, install Cygwin from its website.
  2. How to Set Up a Git Server with SSH on Windows Picture 2How to Set Up a Git Server with SSH on Windows Picture 2
    Then install git and OpenSSH packages, either from the links provided or from within Cygwin's setup utility.
  3. How to Set Up a Git Server with SSH on Windows Picture 3How to Set Up a Git Server with SSH on Windows Picture 3
    Configure OpenSSH:
    1. Open cygwin terminal as admin
    2. Type in 'ssh-host-config -y'
    3. At the end it will create a default user named 'cyg-server' and ask you a new password for that user.
    4. When finished, type in 'net start sshd' to start the openssh server.
  4. How to Set Up a Git Server with SSH on Windows Picture 4How to Set Up a Git Server with SSH on Windows Picture 4
    Make sure your install is working as follows:
    1. Open cygwin terminal as admin
    2. Type 'git' to see if git is working.
    3. type 'ssh cyg-server@localhost' to see if you are able to communicate with the server.
Part 2 of 2:

Git Operations with the Server

  1. How to Set Up a Git Server with SSH on Windows Picture 5How to Set Up a Git Server with SSH on Windows Picture 5
    On your other computer, you can git ssh the server by specifying 'cyg_server@ip_adress_of_open_ssh_server'.
    1. Example to do on the other machine:
      1. Open git bash and check if openssh server is reachable with the command 'ssh cyg_server@cyg_server@ip_adress_of_open_ssh_server'. If it asks for your password, then you are all set up. Otherwise recheck Part 1 instructions.
      2. Open git bash inside the repository you want to push.
      3. add remote with 'git remote add myRemote ssh://cyg_server@ip_adress_of_open_ssh_server/~/git/remote.git'
      4. push with 'git push MyRemote master'
4.2 ★ | 5 Vote