Imran: SSH and Telnet, these are the two main services
that run in Linux to accept connections from outside.
Telnet is an old and unsecured connection
between two computers, and a lot of companies
don't use Telnet anymore.
The SSH is a newer connection established protocol
that is completely secure.
There are two type of packages for most of the services
that you see on a Linux machine.
One is the client package,
and the other one is a server package.
So, you have a server, it sends a connection request,
an SSH request to another server.
So, in this case you are the client,
and the computer you're trying to connect is a server.
So, let's take it the other way.
So, if you on the right-hand side
and the server is on the right-hand side
when it tries to sync its time to you,
as in through the NTP protocol,
then it's no longer the server.
It becomes the client, and then you become the server.
So, let's look at our SSH and Telnet,
both of these little services that we have,
and how they work in a computer.
I will connect it through the PuTTY session,
and I'll confirm I am root.
Let's clear the screen,
and the service that runs, the first one is Telnet.
So, when you run Telnet,
you'll see it says command not found, why?
Because by default now Linux
don't include Telnet in the installation.
So, if you have to install Telnet
you will have to do yum install Telnet.
And it will go to the repositories, and it will find,
it will match the option I have for Telnet.
And it found one package,
and it's telling me do you wanna download?
Now, we will not be using Telnet in our environment,
but if you are troubleshooting Telnet is sometimes a tool
that allows you to troubleshoot some of the issue,
some of the network communication issues.
But for this lesson we'll just skip that,
and we don't want to download that.
Next one we have, the SSH, do we have SSH?
Yes, we do.
That's why we got this usage of SSH.
We could do SSH-2 followed by the IP address
of the remote computer, but since we don't have
a remote computer we'll just say local computer,
which is the same box that we are trying,
we are already logged in to.
When you do hit Enter, yes, you're logging in as root,
so put in the root password.
And you logged in to the same machine
that you were logged in before.
So, you could create as many sessions as you want,
so you could exit out and you'll come back
to your first session.
To check the service of sshd we'll run ps -ef
to see if the process is running.
And you'll see the process is right here.
It says user/sbin/sshd.
This is the process that actually listening
for all the incoming traffic.
If I stop this process I will not be able
to log in to this machine anymore.
But before we do that I wanted to check my IP,
and my IP address is 192.168.1.12.
And let's go ahead and stop the sshd service.
When you hit Enter you get the prompt back.
It means it's not running.
You could do ps -ef again to grep it,
and you will see the sshd and sshd,
this is this already established connections
that it's telling me.
But it is not showing the one we looked before,
which is user/sbin/sshd.
So, it means it will not accept
any incoming sessions anymore.
How can we confirm that?
Let's log in to a new PuTTY session,
and I will put in the IP address
of this machine again, 192.168.1.12.
See it says network error, connection refused
because there is no sshd daemon that is running.
So, we'll click OK, close this out,
and this time we'll start the sshd process.
It is started because we've got a prompt back.
How do we verify it?
You could run ps -ef again, sshd,
and you'll see right here the process is running now.
Now it will accept the connection.
Another way to find out if that service is running
is by doing systemctl status sshd.
And right here it's telling you,
active, active, and running.
So, now if you try to connect to that IP, 192.168.1.12,
you should be able to.
192.168.1.12, bingo, you see how sshd works?
So, this is how you could stop the connection
to your server or refine or restrict your computer.
This is a way to, an enhanced way
to implement security on your system.