Solving the a client side SSH connection error - linux

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).

Related

ssh: connect to host ********* port 22: Connection timed out

I have Ubuntu 22.04 newly installed on my laptop. I am trying to connect to a remote server and getting the following error:
ssh: connect to host ********* port 22: Connection timed out
I tried some solutions which include,
ping the IP address
adding the IP address to the firewall using sudo ufw
installing ssh and openssh
However, nothing seems to work. I'd be thankful if someone can help me to solve this problem.
If you can ping the server it can be the following causes:
The server is not answering ssh, sometimes ssh server is not up or it is answering in another port.
There is a firewall blocking your request.
You do not need to install the openssh server in your computer to access a remote hosts and normally outbound connections are allowed by ufw.
ssh: connect to host ********* port 22: Connection timed out
I have this kind of problem too I contact the server admin and said the operation system should be install again due to some problems
after re installing the problem solved try it it may works

I can't clone on gitlab with ssh

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.

Node Js ssh: connect to host port 22. No route to host

Hi I in an attempt to connect to more than one aws account I did a number of stuff that has led to this error. "ssh: connect to host abc.com port 22: No route to host" I dont know what the problem is or how to solve it.
This kind of issue occurs mostly due to following reasons:
Maybe your device is not properly connected to internet. Check your internet connection and try to load again.
May be config file has incorrect information. Check your config file has correct information. Check your ssh directory and ensure that ssh key exists.

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

SSH connection on ec2

I'm trying to connect to an AWS ec2 instance but I keep being refused.
I'm using the same computer, the same wifi but suddenly when I connect to one of my ec2 instance, it fails.
when I connect, it says..
ssh -i successintoeflcom.pem ec2-user#52.68.152.179
ssh: connect to host 52.68.152.179 port 22: Connection refused
ssh -v successintoeflcom.pem ec2-user#52.68.152.179
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 26: Applying options for *
ssh: Could not resolve hostname successintoeflcom.pem: nodename nor servname provided, or not known
I looked at /etc/ssh_config line 26, and found
Host *
SendEnv LANG LC_*
something got to be wrong, but I haven't found a way to make it right.
I also tried deleting the ec2 instance and make new one with new ssh key and new EIP but it did not work.
honestly, I'm new to ssh settings. Any help would be appreciated.
PS
For some reason, I was able to connect to other ec2 instance that is on other aws account, which I use for work.
Start with checking the VPC configuration: ensure the internet gateway is associated properly with the subnet; ensure the SSH port (22) is opened in both the security group and the network ACL.
You can follow the guide and the troubleshooting described in the blog-post configure VPC and create SSH connection to a Linux-based EC2. It touches the traffic rules configuration and explains how to define the SSH keys properly.
Check the Security groups inbound settings, make sure ssh protocol
enabled with source as anywhere. Because your System IP address might
change.
Check with .pem file permission. It should be set with chmod 600.

Resources