0

I am under Ubuntu 16.04. I cannot clone any repository (i.e. git://yoctoproject.org/poky ; git://git.gnome.org/jhbuild ; git://git.gnome.org/rhythmbox etc.) under the git protocol.

I generated public and private ssh keys with ssh-keygen and put them on the folder ~/.ssh/ .

It works with downloading git repositories under https protocol (like https://github.com/mozilla/gecko-dev). I have tried the option "use https:// instead of git://" for cloning the above git repos but it did not work. I checked with different internet connections (home and work), removed the proxy, but it did not work.

The errors i get when I try to clone are: - fatal: unable to connect to "hostname" ; errno=Connection timeout / no error. - ssh: connect to host "hostname" port 22: connection timed out Please make sure you have the correct access rights and the repository exists.

My idea is that in some way for every git:// repository I need to add my public key to the host authorized_keys folder, but I do not know how to do it (and if it is the solution to my problem). Can someone please give me a working example on how to clone a repo with git:// protocol?

Carlo Benussi
  • 165
  • 1
  • 14
  • Are you sure you are using (or should use) the git:// protocol? According to the [documentation](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols), the git protocal has *no* authentication and is very rarely used. Most likely you should use the SSH protocol. In this case, some server-side software may also pose restrictions (e.g. gitlab or github, which require to always use the `git` username). – Martin Nyolt Aug 31 '16 at 15:08
  • If you are using the SSH protocol, you probably also have to specify which private key to use in the `~/.ssh/config` file. (hint: `HostName xyz` - `IdentityFile abc_rsa`) – Martin Nyolt Aug 31 '16 at 15:12

2 Answers2

0

My idea is that in some way for every git:// repository I need to add my public key to the host authorized_keys folder, but I do not know how to do it (and if it is the solution to my problem).

Have you access to the machine where the repository is running? If yes, you can use the following command to copy your public key to the server:

cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

If you don't have access to the machine, you can send (email) your public key to the admin.

Can someone please give me a working example on how to clone a repo with git:// protocol?

When you have access to the repository, use this:

git clone git@123.45.56.78:/opt/git/repository.git
0

I had the same issue wherein I was able to clone any repo under ssh:// or http:// protocol, but would fail only while using git:// protocol. I could overcome the issue. You need to setup gitproxy. Requirement is any bi-directional relay tool such as socat

Create a gitproxy file in your home environment. Include this line after declaring your PROXY

exec socat STDIO SOCKS4:$PROXY:$1:$2

Add this line in your ~/.gitconfig [core] tab:

gitproxy = /home/<linux username>/bin/gitproxy

Make it an executable:

chmod +x ~/.gitproxy
Sachin Mokashi
  • 415
  • 5
  • 17