Reputation: 4079
SSH has been working fine for the last few weeks since I got my new PC. I've had no problems but today I started getting:
ssh: connect to host github.com port 22: resource temporarily unavailable
I did some googling and found that there is a common issue with WSL which sometimes causes this, but I'm unable to SSH from my bash shell, or from cmd/powershell.
This is the part that confuses me, if I do: ssh -T [email protected]
I am prompted for the password to my key, it successfully authenticates and responds with "Hi alexmk92! You've successfully authenticated".
Great, that at least proves that my firewall isn't blocking SSH on port 22. But why does [email protected]
throw the resource failed error? My initial thought is that this could be a DNS problem.
So I tried to configure my network adapter to use Google's DNS server (8.8.8.8
and 8.8.4.4
) I even configured the IPV6 DNS servers just in case. Following this I did an ipconfig /flushdns
, attempted to connect via [email protected]
again and BAM the same result, however [email protected]
still works.
I'm guessing another potential cause is that github.com
is behind a load balancer and one of the IP's on the cluster could be black-listed somewhere on my machine? I'm just pulling guesses out of thin air now, any help would be greatly appreciated, this is driving me insane.
Upvotes: 3
Views: 4308
Reputation: 4079
After some further Googling it turned out that my machine did not have a hosts entry for github.com and it was unable to automatically resolve it.
In Windows Subsystem for Linux I created a ssh config file
touch ~/.ssh/config
(for some reason the base distro of Ubuntu 18.04 on the windows marketplace didn't have one) I then had to make sure the file permissions were correct:
chmod 755 ~/.ssh/config
Once the file was created, I edited it with
sudo nano ~/.ssh/config
and added github.com
as a Host.
Host github.com
Hostname ssh.github.com
Port 22
Upon saving, I ran
sudo /etc/init.d/ssh restart
and attempted
ssh -T [email protected]
Everything now seems to be working.
Upvotes: 4
Reputation: 415
In my case my ISP did not allow ssh, so it was not working from cmd and wsl both. Got around it using vpn
Upvotes: 1
Reputation: 582
To have successful SSH connection to Github, SSH key has to be import into Github
ssh-keygen
A private and a public key gets generated in the folder * < user_home>/.ssh/*
Upvotes: 0