- All right, our next topic is about SSH.
SSH is secure shell.
Why would you want to use secure shell?
Well, for the simple reason
that it provides a remote shell access.
The thing is that many people are working with Linux
but they are working with Linux in cloud
or as a virtual machine.
And if that's the case
you have no direct access to your Linux machine.
That is why you need secure shell.
In order to use secure shell
you need to install it and you need to enable it.
If you're on Ubuntu,
sudo apt install openssh-server.
And if you're on Red Hat,
well by default on Red Hat,
you will find that ssh is normally already installed.
If that is not the case,
sudo dnf install openssh-server
followed by sudo systemctl enable.
The (indistinct) is now sshd.
Next,
you need an SSH client to access the SSH server.
If you're on Linux and MacOS,
a native command line SSH client is available.
If you're on Windows you can use MobaXterm.
MobaXterm is an easy to use Windows utility
in which you enter the IP address of your target machine
and you can easily connect to your target machine using SSH.
Now, SCP is a convenient tool that allows you to copy files
from the local computer to the remote computer.
And why am I mentioning it here?
For the simple reason that SCP is a part of the SSH package.
So you install SSH,
you get SCP for free.
So the command looks like scp/etc/hosts
to 192.168.29.111:/tmp/.
And you can see that the 192.168.29.111,
that's the name of the server.
And the name of the server has a colon behind it
and after that, there's the path.
Now let me demonstrate how we can get started with SSH.
So for this demo I'm starting on Ubuntu,
using sudo apt install openssh-server.
Because on Ubuntu you don't get SSH by default.
Well, depends on Ubuntu server.
There's an option that is asking you,
hey, do you want to install OpenSSH?
And if you answer yes, you get it,
but otherwise you don't.
Now I'm going to use ip a.
Ip a, one of the first commands that we learned about,
is showing me that this Ubuntu machine
is 192.168.29.142.
That's the IP address that I'm going to use.
So let me go to the CentOS machine.
And from the CentOS machine
I'm using ssh student@192.168.29.141.
And there we go.
This is what's happening the first time
that you make connection with the remote SSH server.
It's probably complaining about some key fingerprint.
What is that?
That's the identity.
The SSH client is keeping the identity of the host
that it has connected with in the past.
That's an additional level of security.
So if you answer yes,
you store the identity locally,
and the next time that you log in to this remote server
you will not be prompted anymore.
Your local client knows that you are on the right server.
And oops, do you see that?
I opened an SSH session to myself.
That's not what I wanted.
I wanted to go to Ubuntu, 142.
Aha, let's try it again, 142.
Again, the prompt for the identity,
I'm entering my student password,
and look at that, welcome to Ubuntu.
I'm on Ubuntu and I can do whatever I want.
Well, you know what I want?
I want to create a file,
echo greetings from ubuntu
to ubunut.txt.
What is ubunut?
That's just a file name.
And I'm going to use scp of ubunut.txt
to 192.168.29.141:/tmp/.
That's the SCP command,
and SCP is pretty convenient as well.
So I'm entering yes because I want to copy it over.
And there we go,
I'm copying it over using the student account.
Now you can also copy it over using another user account.
In SSH you can always use username@.
Username@ in front of the name of your server
will connect as that specific user.
Now it happens to be that on CentOS there's the root user.
So I am being prompted for the root user password here,
and that is copying ubunut to the root user home directory.
So if I use sudo cat /root/ubunut.txt,
then you can see greetings from ubuntu.
And hey, did you notice?
I wasn't prompted for any sudo password.
So it seems that my sudo cat is working the way I wanted it.
That's all for now.