How to create my own Git server?

7

I'm trying to work with Git and some problems arise, the scheme is as follows:

I have two PCs in my house, one I want as a server, to host my projects and the other I want to clone these projects. The problem arises when cloning. The two PCs have Linux and created the users git and their emails.

The PC acting as server has a repository created in the following path: var/www/html/carpeta_del_proyecto/repositorio.git

And from the client PC I want to clone it. I have read that there are several access methods like git , ssh and 'http.

I have generated the keys ssh from the client and the server, and the key ssh public of my client I have already added it to the file /.ssh/authorized_keys of my server.

What am I doing wrong that I can not clone? I tried the following commands:

  • git clone [email protected]_local_servidor/usuario_servidor/ruta_del_repo/repositorio.git

  • git clone [email protected]_pública_servidor/usuario_servidor/ruta_del_repo/repositorio.git

  • git clone ssh://[email protected]_pública_servidor/ruta_del_repo/repositorio.git

  • git clone http://ip_pública_servidor/usuario_servidor/ruta_del_repo/repositorio.git

  • git clone+ssh://usuario_servidor/ruta_del_repo/repositorio.git

  • The last one (number 5) I'm not sure, just copy it from the internet and edit the user and the route, but the header clone+ssh is not if it is left like this or refers to something else.

    I would appreciate it if you can help me and respond, I am trying this for weeks and I can not achieve it. Thank you very much already.

    Pd: I have tried with different IPs , the local one that is given by my router, and the public one when I connect to the internet. Example 1 and 2 are the same only have different IPs .

        
    asked by FabricioNahuel 02.02.2016 в 04:58
    source

    2 answers

    3

    In the end the problem I had was that the ports were closed and that's why I could not access from the PC where I wanted to clone it.

    I opened a server port with the following command:

    $ sudo ufw allow <número de puerto>
    

    I removed it from this page: Configure the firewall UWF in Ubuntu

    Then I had to configure my router to do a port mapping (I opened a port rel router and connected it to the open port of the server), this varies according to the router and its configuration ( You can search or find NAT in such configuration).

    Once this was done I checked if the ports were open with the following page: Scan online de ports

    And finally I created a No-IP account, installed its client and configured it to associate my Public IP with a name that I would like to add to my < em> DNS . This way I could already clone my repository with the following line:

    git clone ssh://[email protected]_del_dns:puerto_abierto_del_router/ruta_del_repo
    
        
    answered by 10.01.2017 / 17:25
    source
    3

    I think the route you're using to access your repository is not the correct one. The command that you should use would be this:

    git clone [email protected]_servidor:/var/www/html/carpeta_del_proyecto/repositorio.git
    

    Also, you could have a permissions problem, to make sure you could use the scp command and verify if that user has read and write permissions on that folder and if access is working for ssh . If you are going to have a single user, placing the repository in the user's folder could simplify it.

    Check out this link where you have documented how to create a Git server

    You could also set up a more advanced server using the Community edition of GitLab , but that already depends on your needs.

        
    answered by 02.02.2016 в 08:21