There are few features that are not available out of the box in Ubuntu. One among such feature is SSH. If you ever install Ubuntu on your machine and expect the ssh to work by default, it doesn’t. You would get an error message that says ‘The remote system refused the connection’
And for me, being from the network background I really needed this ssh access and certain network tools as well, such as traceroute, arp table, and so on.
In this blog lets enable ssh and basic network tools in Ubuntu, eventually how to fix traceroute issue in Ubuntu.
- You must have Ubuntu machine installed with root access on your machine with internet access.
What is SSH ?
An SSH (secure socket shell) is a protocol that will let you connect to remote hosts’ command-line interface securely. Since it is encrypted no one can read the data between the SSH server and the client. The default port that is used by the SSH is 22.
Can I use Telnet instead of SSH?
Yes of course you can, but the problem would be if anyone was able to access the session between the telnet client and the server, then they can easily read the session. As the communication that happens in cleartext format and there is no encryption in place.
How to install telnet client in ubuntu?
To install the telnet you can enter the below command.
sudo apt-get install telnetd -y
Telnet to find open ports
But there is a very good use case for the telnet, which is to identify the open ports on a specific IP address.
For example, if someone is telling you that they are unable to access HTTP traffic on some IP, all you can do is type the command
telnet <server IP> 80
If it’s shows connected which means the port is open. Let me show you an example with a google IP address.
I did nslookup to www.google.com and I got the IP address 220.127.116.11, you must know that the HTTP and HTTPS traffic should be allowed on this IP, so let’s check that.
To check HTTP traffic you can type
telnet <ip address> 80 , as you can see in the output below that it says it is connected which means that this port is open.
Lets check https, which is 443. And that is also open.
How about ssh, do you think google would open the SSH port to their IP’s ?
As you can see it is trying but never get connected, which means that the port is not open.
If you are trying to use Telnet to access any of the network hosts, you need to use port number 23.
How to enable ssh access on Ubuntu ?
To enable SSH service on the Ubuntu machine you will have to download and install the utility called OpenSSH. Let’s go ahead and install the OpenSSH utility on my Ubuntu desktop.
Note: During the installation of the Ubuntu Server, it should ask you whether you would like to install the OpenSSH service or not, if you failed to do you can follow the same steps here and you should be able to install them on your Ubuntu server as well.
Step 1. Login to the terminal.
If you are using Ubuntu Desktop type CTRL+ALT+T , or right click on Desktop and click on Open in Terminal
Step 2. Install Open ssh server
You can install the OpenSSH service by entering the below commands.
sudo apt update sudo apt install openssh-server -y
Step 3. Check the SSH service status.
Once the installation is completed the Openssh service would start by default. Let’s quickly check the status of ssh service on the machine by running the command
service ssh status.
As you can see the ssh service not only installed, it has also been started automatically.
At any point, if the ssh service has not started you can enter the command
service ssh start to start the service.
To stop the service type
service ssh stop and you can also restart the services by typing
service ssh restart just like how you would manage any other services in Linux.
Step 4. SSH into the Ubuntu host.
You can use ssh [email protected] address to ssh into the machine from another Linux box or use any ssh client software.
I tried to SSH from a different Ubuntu machine and as you can see it is prompting me to enter the credentials now. Thich is good, let’s also try to access from another SSH client as well, which was not working initially.
The last time when I tried to SSH from the secure CRT client, it was saying the connection was refused, this time as you can see it is prompting me to enter the credentials.
And I am able to login via ssh after I entered the Ubuntu machine credentials from ssh client.
Installation of Basic network utilities in Ubuntu.
Just like SSH, if you ever try to check ARP entries by typing
arp -a, or checking the route table by typing
netstat -rn or
route -n, you get the error saying the command not found.
To install ARP, Route and Network we need to use a utility called net tools package.
All these utilities are included in the net tools package, let go ahead and download and install them by typing
sudo apt install net-tools -y
After few seconds all the packages are installed successfully.
Net-tools verification in ubuntu
- When I ran the
arp -aI could see all the arp entries in the system.
- Let me run the command
route -nto see my route table
netstat -rnto see the route table
Note : By default, the ubuntu has built in tool called
ip route to check the routing table instead of route -n or netstat -rn
- IP route command would show the route output slightly differently than other utilities that we mentioned above.
Access traceroute on Ubuntu
One of the network utility that many of the network admins use in Ubuntu is the traceroute utility which would help them to see the path for a specific network.
You can install the traceroute package by running
sudo apt install inetutils-traceroute -y
Unfortunately, when you try to run the traceroute in ubuntu it would not just show the path instead it just throws some asterisk signs. Which many network engineers tend to believe that the network is not reachable or something is blocking the network. However, that’s not the case.
The workaround for this is,
Instead of using the traceroute utility, I would recommend you to use the MTR utility (My Traceroute ), and it just works.
- To run MTR, type MTR and the IP that would like to trace.
- Below is the output for the tracroute I ran for the google DNS IP 18.104.22.168
And best part is MTR is installed by default in Ubuntu.