I can't clone on gitlab with ssh - gitlab

I can clone over https just fine but after I connect my ssh key, I keep getting the following error:
ssh: connect to host gitlab.example.com port 22: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I've tried deleting and recreating the ssh key and adjusting the config port to 443 and nothing has worked.

If this is an on-premise GitLab installation (meaning not gitlab.com), chances are port 22 is should not be blocked.
Double-check that with:
curl -v telnet://gitlab.example.com:22
Switching to 443 would rather involve HTTPS. (github.com does have an SSH listener on port 443 or ssh.github.com, but that is probably not the case for your own GitLab server), unless your server is configured to do so on altssh.gitlab.example.com.

Related

Solving the a client side SSH connection error

Essentially I cannot connect to an SSH server anymore. Whenever I try to connect I get the following error:
ssh: connect to host HOSTNAME port 22: Connection refused
Note that I am able to connect from a different machine. Hence, the issue seems to be client side. Furthermore, I also cannot pull/push to git repositories that are cloned via ssh. Again, when pulling I get the following error:
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
It seems like I somehow nuked my SSH installations/config files. I have reinstalled SSH but this did not fix the problem. Any ideas?
Note that you never "connect" to github.com directly (no interactive shell)
As mentioned here, "Connection refused" means
invalid IP address for github.com (manual entry in /etc/hosts or your resolver)
firewall along the way to github.com which blocks the ssh traffic (eg. local firewall or corporate firewall)
So is the other machine (where you do succeed) on the same network?
Check if the other machine SSH config file was not using ssh.gthub.com port 443 (instead of the default github.com:22, typically blocked in a corporate environment).

Network is unreachable when I clone my bitbucket repo in private AWS instance

I am trying to clone my bitbucket repository into my private AWS instance but it is giving me a 'network is unreachable' error.
I have successfully established a connection to the private instance using bastion host and I'm able to access it but when I'm trying to git clone my repository it is just timing out with the error:
ssh: connect to host altssh.bitbucket.org port 443: Network is unreachable
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Are you able to clone git repos from other servers, if yes, then it can be because of Security Group rule between the instance and Git is not in place or the Firewalld service running at the OS level
You can use telnet command to troubleshoot the issue further from the instance you are trying to clone git repo
telnet altssh.bitbucket.org 443

git clone failed to begin relaying via HTTP

When Using git clone, I come into an error.
Here is the command and the error information.
[user#linux]$ git clone git#github.com:username/repertory.git
FATAL: failed to begin relaying via HTTP.
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Except for git#github, git clone https://...... and git clone git://...... works well. So i guess there is something wrong with ssh protocal, then i checked ssh.
[user#linux]$ ssh -T git#github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
It seems that I can connect to github through ssh protocol properly. But what's wrong with git clone through ssh?
This error message comes from connect.c from SSH
It is a SSH Proxy Command -- connect.c, the simple relaying command to make network connection via SOCKS and https proxy: You can make SSH session beyond the firewall with this command.
So check if such a connection is needed: it could very well be needed if you are in an enterprise, behind firewall, but in that case do contact your IT support team to check the validity/approval of such a solution.
And that error message indicates that even this SSH mode (relay through https proxy) might be blocked.
If you are not in an enterprise setting, and don't need proxy, do remove them (HTTPS(S)/PROXY) from your environment variables and your git config file.
If you're using a Proxy, many corporate firewalls block access to the CONNECT method on ports other than 443. GitHub operates an SSH server listening on port 443, using the host "ssh.github.com".
First, configure your SSH ~/.ssh/config with the following:
Host github.com, ssh.github.com
User git
Hostname ssh.github.com
Port 443
ProxyCommand socat - PROXY:localhost:%h:%p,proxyport=3128
in the example above I'm assuming you're running a web proxy on host localhost and port 3128 (e.g. cntlm).
You may also substitute socat with nc or connect-proxy with slightly different syntax.
Test with:
ssh -T git#ssh.github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
then with:
git clone git#ssh.github.com:username/repository.git

Unable to clone github repository

I have generated ssh keys from my terminal and placed an entry in my SSH keys section in github.com.
After that, I am just trying to clone my repository, but I get the following error message :
git clone git#github.com:XYZXY/XXXXXXXXXX.git
Initialized empty Git repository in /home/XYZXY/.ssh/XXXXXXXXXXXXX/.git/
ssh: connect to host ssh.github.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
I tried this one too :
ssh -T git#github.com
ssh: connect to host ssh.github.com port 22: Connection refused
My question is :
1) Is source side blocking the connection ?
2) Is Target not allowing the connection ?
Try running this command for more information.
telnet ssh.github.com 22
You should see something like this.
~ $ telnet ssh.github.com 22
Trying 192.30.253.122...
Connected to ssh.github.com.
Escape character is '^]'.
SSH-2.0-libssh-0.7.0
If you do not, then something (possibly a firewall block?) is preventing you from accessing github.

creation of local git repository fails

I am tyring to create a local git repository with this command on ubuntu 14.10, but it fails with error "you don't have correct access rights". Any idea what could be the problem?, is it a firewall issus?
$git clone -o khronos git#gitlab.khronos.org:vulkan/LoaderAndTools.git .
Cloning into '.'...
ssh: connect to host gitlab.khronos.org port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Thanks
The Connection timed out message indicates that your machine cannot connect to port 22.
As I can reach gitlab.khronos.org port 22 fine, my conclusion would be that it is a firewall in your local network that is the problem.

Resources