Let's talk about Secure Shell.
By default, all RHEL servers run a Secure Shell server.
And the Secure Shell server allows remote access.
To verify that it runs, use systemctl.
Systemctl is the main management command for systemd.
And systemctl status sshd should confirm that it is running.
By default, SSH is allowed through the firewall.
So you don't typically have to do anything about it.
And by default, root user access is denied.
But that shouldn't matter because you don't want to log in as a root user anyway because
a root user doesn't have a password.
So what you do, you use SSH to connect to a remote server.
And on that remote server, you can use sudo if you want to do super user things.
Now on the remote server, you can use IPA to find the IP address.
Because in order to connect to the remote server, you need to know the IP address.
So IPA will show you.
And then you can use SSH based on the IP address.
Or if it has a name that is resolvable, you can use the name as well to connect to the
server.
If you don't specify user information, then you will connect using your current user account.
You can also use SSH username at some IP address to connect as a specific user.
And also convenient is that you can run a single command on a remote host.
Just pass it as an argument to your SSH command.
Like SSH user at IP address, who am I, for instance.
Before telling you about secure copy, let me show you how to work with SSH.
So first, a couple of checks.
I'm not going to work with a real remote server.
But I'm going to treat my local server as if it were the remote server.
So system CTL status SSHD is showing that SSH is active and running.
Well, that's all that I need to know about.
Then IPA is showing the IP address for my server.
Here on the interface ENS 160, that's the name of my network card.
I can see my IP address is set to 192.168.29.141.
So if I use SSH student at 192.168.29.141, then this is happening.
What is this?
Well, it's telling us that the authenticity of the host can't be established.
Every time you connect to a remote host using SSH,
you are going to get an ED25519 key fingerprint
that allows you to verify the identity of the remote host.
And this is the first time I'm connecting to this host.
So it doesn't know the key fingerprint.
And that is why it's telling me, hey, are you sure you want to continue connecting?
Yes, I am sure.
At this time, the SSH key fingerprint is stored to the local user home directory.
And I'm prompted for the remote user password.
And there we can see that I'm now logged in to the remote host.
And I know it's the same host, but hey, you don't really have to have a remote host
to test if SSH access is running.
So here I'm in my SSH server.
And when I'm using exit, I'm back on my regular server again.
Obviously, this also works with real remote servers.
So I happen to have a real remote server as well, by the way.
So let me try that.
And this time use SSH student at 142.
Again, first time I'm connecting, so it's not sure about it.
And I'm entering my password.
And now I'm on the server with the name localhost.
Different IP address, different server, different user home directory.
And work on the remote server as long as you want and type exit when you are done.
Now, as a part of SSH, there is the SCP command.
SCP is for secure copy.
And that happens to be a very convenient command.
So SCP is a part of SSH.
And it allows you to copy files securely.
If you know how CP works, you also know how SCP works.
So you use SCP followed by the name of the file that you want to copy
and followed by the location where you want to copy it to.
The only requirement is that the remote server needs to be running an SSH process
that is accessible through the firewall.
As I mentioned before, it will be accessible through the firewall by default.
So let's have a look.
So I'm using SCP of etcpasswd to student at 192.168.29.142 colon slash tmp.
Now, there is a small challenge.
And the challenge is that the root user doesn't have direct access to the remote server.
So I'm just copying it to the tmp directory as a temporary solution.
And from there on the remote server, I can do whatever I want to do with it.
Let's verify that it worked out the right way.
So SSH student at 192.168.29.142 ls minus l slash tmp passwd.
And of course, I need to enter the password again.
And as you can see, the file was successfully copied.
There you go.