I'm trying to work with Git
and I'm running into some problems. 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 those projects. The problem arises when cloning. The two PCs have Linux and created the users git
and their emails.
The PC that acts as a 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 accessor methods like git
, ssh
and http
.
I have generated the keys ssh
from the client and the server, and the ssh
public key of my client I have already added to /.ssh/authorized_keys
my server file.
What am I doing wrong that I can't clone it?
I have tried the following commands:
git clone git@ip_local_servidor/usuario_servidor/ruta_del_repo/repositorio.git
git clone git@ip_pública_servidor/usuario_servidor/ruta_del_repo/repositorio.git
git clone ssh://usuario_servidor@ip_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, I just copied it from the internet and edited the user and the path, but clone+ssh
I don't know if the header is left like that or refers to something else.
I would appreciate if you can help me and answer, I've been trying this for weeks and I can't get it. From already thank you very much.
PS: I have tried different ones 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, they just have different IPs
.
I think the path you are using to access your repository is not correct. The command you should use would be this:
Also, you could have a permissions problem, to make sure you could use the command
scp
and check if that user has read and write permissions on that folder and if access is working for youssh
. If you're going to have a single user, placing the repository in the user folder might simplify it.Take a look at 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 depends on your needs.
In the end, the problem I had was that the ports were closed and that's why I couldn't access it from the PC where I wanted to clone it.
I opened a server port with the following command:
I got it from this page: Configure UWF Firewall in Ubuntu
Then I had to configure my router to do port mapping (I opened a rel router port and connected it to the open port of the server), this varies depending on the router and its configuration (You can search or find it as NAT in said configuration ).
Once this was done, I checked if the ports were open with the following page: Online port scan
And finally I created a No-IP account , installed your client and configured it to associate my public IP to a name that I would like to put in my DNS . In this way I could already clone my repository with the following line: