SSH: COULD NOT RESOLVE HOSTNAME. . . GITHUB ERROR

This tutorial/guide is about the error in the box below.

ssh: Could not resolve hostname github.com: Temporary failure...
fatal: Could not read from...

You may be getting this error because you generated an ssh for your local machine and didn’t add it to your GitHub account or because you added an ssh key to your GitHub account. This may also happen for some other reasons.

There are 2 ways I’ve fixed this on my machine:

1. I can either generate an ssh for my local machine and then add it to my GitHub account. 

2. I can push my app to GitHub using https instead of ssh. <This should work for both Windows and Linux users, but I haven’t tried it on Linux yet>

Let’s try step one, I’ll guide you:

You’ve pushed your app and it returns the above error (this step is for Linux users) ,

cd /home/username/.ssh

ls 

In this directory, you should see a file “known_hosts”. We’ll generate the ssh key in here.

ssh-keygen

That should generate “id_rsa” and “id_rsa.pub”. If you have those keys in the directory already, then there’s no need to generate them. Just move on to the next step. . .

cat id_rsa.pub

Copy the key and head over to your GitHub account. Open the user tab on the top right corner and click Settings.Click on SSH and GPG keys.Click on New SSH Key button. Add a title and paste your key in there, then click the Add SSH Key buttonOver to your terminal, type

ssh -T git@github.com

You should get a message:

Warning: Permanently added ‘github.com. . .Hi username! You’ve successfully authenticated. . .

Try to push to your repository again

git push -u origin master

That should fix it.

2. After creating your empty repository at GitHub, you appear at this page that gives you the steps on how to push your app to your repository. At the top of this page, you should see https and ssh buttons and its always on ssh. Click the https button and try the steps you get. If after pushing you get the same error, type. . .

git remote set-url origin https://github.com/username/reponame

and then. . .

git push origin master

those are the steps I’ve used and they always works, hope they help if you ever encounter such problems.