SSH, git, sftp can't resolve hostnames (Ubuntu)

0

UPDATE: Reinstalling SSH fixed the issue.

A few days ago I deleted the ~/.ssh/known_hosts file because it was owned by root and my user had no permissions on the file. Googling told me that it was fine to delete because a new one would be generated automatically when I next tried to SSH somewhere.

The next day I upgraded from Ubuntu 17.04 to 17.10.

I then tried to clone a repo from GitHub, but was met with this:

git clone git@github.com:xxxxxxx/psb.git

Cloning into 'psb'...
ssh: Could not resolve hostname github.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This also occurs when attempting to use the HTTPS clone URL:

git clone https://github.com/xxxxxxx/psb.git

Cloning into 'psb'...
fatal: unable to access 'https://github.com/xxxxxxx/psb.git/': Could not resolve host: github.com

Additionally, FileZilla shows this error when trying to use SFTP:

Command:    open "xxxxxxxx@coreteaching01.csit.rmit.edu.au" 22
Error:  ssh_init: Name or service not known
Error:  Could not connect to server

And SSH in the terminal does the same:

ssh xxxxxxxx@coreteaching01.csit.rmit.edu.au
ssh: Could not resolve hostname coreteaching01.csit.rmit.edu.au: Name or service not known

Contents of /etc/resolv.conf:

cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

Content of /etc/hosts:

cat /etc/hosts

127.0.0.1 localhost
127.0.1.1 laptop

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

This happens when trying to update Oh My Zsh:

[Oh My Zsh] Would you like to check for updates? [Y/n]: yes
Updating Oh My Zsh
fatal: unable to access 'https://github.com/robbyrussell/oh-my-
zsh.git/': Could not resolve host: github.com
There was an error updating. Try again later?

And I get these responses when using nslookup:

nslookup github.com

Server:     127.0.0.53
Address:    127.0.0.53#53

** server can't find github.com: SERVFAIL

And:

nslookup google.com
 
Server:     127.0.0.53
Address:    127.0.0.53#53

** server can't find google.com: SERVFAIL

I have tried the git config --global --unset http.proxy solution mentioned in similar questions, but that had no affect.

I have also tried changing the nameservers for my WiFi connection (the only network connection) to 8.8.8.8 and 8.8.4.4, but I'm not sure if this stuck or why the normal nameservers would suddenly stop working for SSH.

I have also tried service network-manager restart as well as hard and soft rebooting.

Other things like Chrome, Dropbox, Slack, apt, ping work fine.

I'm not sure where to look next.

Gary David Hill

Posted 2018-03-01T04:56:42.877

Reputation: 1

resinstall ssh? Also, chown is your friend – mcalex – 2018-03-01T06:22:58.097

1This looks like you are running a local DNS proxy that's misconfigured (127.0.0.53 is an alias of localhost). Try to find it (ps axu, or check installed packages), and either configure it correctly, or remove it. – dirkt – 2018-03-01T07:30:53.383

No answers