If you’re sure that you have a solid connection, then you should next check for any typographical errors. You may have mistyped an IP address or some sort of resource locator line. While it might seem picky about the way information gets presented to it, the ssh software wants to make sure you’re always connecting to the right resource. In addition, your hosts file might also ultimately point ssh in the wrong direction as to the resource you’re attempting to connect to.
Method 1: Resolving Malformed Hostname Commands
Assuming you didn’t make a mistake like typing s sh or ss h instead of ssh, then you might have malformed the hostname command. The software expects commands given as ssh user@NAME instead of some other format. Open up a terminal with the appropriate privileges for your command. You’ll generally be able to operate as a regular user when using ssh and you won’t need superuser powers. You may want to open a terminal by holding down Ctrl, Alt and T at the same time. Some Xfce4 users can hold down the Windows or Super key and push T. You can start a prompt from the Dash, Applications, KDE or Whisker menu by heading to search and typing Terminal or instead by selecting it from system tools. Users of Ubuntu Server or versions of Red Hat Enterprise Linux and Scientific Linux that don’t have a graphical user interface should hold down Ctrl, Alt and F1-F6 to access a virtual console. You’ll need to log in before proceeding. Once you’re at a prompt, issue your ssh code and make sure it’s in the previous format. For instance, you could try ssh root@myPlace if you had a hostname connected on your network as such. The command ssh root@##.#.#.##, having replaced the octothorpe symbols with numbers, is a good idea if you’re connecting directly to an IP address.
You may find you were writing root@server or something else similar, which would spit out this following error: Some users make a habit of reminding themselves that ssh user@server is the way you always need to write this command out.
Method 2: Correcting the File
Any sort of damage to the file can also cause hostname problems, and ssh will sometimes offer the same warnings for these types of errors that it would offer for anything else. You’ll need root access to open the hosts file. If you’re working on one of the terminals from above, then you can type sudo nano or to open the file for editing. The sudo prompt will request your password. If you’re working from inside of a desktop environment, then you’ll want to open an application line. You can do so by holding down the Windows or Super key and R, pushing Alt and F2 or clicking on the Dash depending on which desktop environment you’re using. When you have a line, type depending on whether you’re using GTK+ or KDE Qt based applications. You may want to use gvim, leafpad or mousepad instead of gedit or kate. You’ll have loaded the hosts file in any case. Make sure you have read and write access then take a look at the top of the file. You’ll need the following two lines for it work correctly: YourHostName should feature your machine’s actual hostname. You may need these as well if you’re working with an IPv6 network: 127.0.1.1 YourHostName If you’re on some sort of network that only uses IPv4 technology, then you will only need to correctly set the first two in a majority of situations. Modern Internet connectivity is quickly migrating toward the IPv6 standard, however, so the days of setting these alone are quickly vanishing. Your Linux distribution should have configured these settings for you, but sometimes an errant package or simply user errors can corrupt the hosts file and point connections in the wrong location. fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
If you’re using a graphical text editor that reads
How to Fix ‘Can’t Resolve Hostname’ Error on MinecraftCreate SSH key pair in Microsoft Azure and add it to Ubuntu ServerHow To Access Graphical User Interface (GUI) Of Raspberry Pi Using SSH And VNC…Your Guide To Using SSH