SSH, also known as Secure Shell, is a network protocol used by system administrators to securely 1
configure a remote system over an unsecure network connection. 2
It's, in fact, the most useful network protocol used for the remote management of servers, routers, 3
switches or other networking devices. 4
SSH involves a client and a server. 5
The SSH client creates a secure connection to the SSH server on a remote machine, and then the connection 6
will be used to execute commands on the server. 7
Let's install OpenSSH, which is the most used SSH server, on both Ubuntu and Centos: 8
On Ubuntu I’m running as root: apt update && apt install openssh-server and 9
openssh-client 10
It's installing or updating it. 11
OK, and on Centos, I'm running 12
sudo dnf install openssh-server openssh-clients ending in an s 13
They were installed or updated; when the installation is complete, you can verify the status of the SSH 14
server by running systemstl status ssh on Ubuntu and systemctl status sshd on Centos. 15
So on Centos systemctl status sshd It's active and running and on Ubuntu 16
It is active in running as well. 17
The difference is that on Centos the systemd unit is called sshd instead of ssh on Ubuntu 18
d at the end comes from daemon. 19
You can also take a look at and search for it in the processes list. 20
So ps -ef | grep sshd And it's running; and the same on Ubuntu; the daemon is running. The 21
name of the process is sshd on both Ubuntu and Centoes. To check if it's enabled or set to start at 22
boot run: systemctl is-enabled ssh 23
And it's enabled; it means it will start at the boot time. 24
Let's connect to the ssh server. In the next example, Ubuntu will be the ssh server in the Centos the ssh 25
client. Before continuing 26
my advice is to check the network connection between the ssh client and the server using ping. Let's see the 27
IP address of Ubuntu. 28
And I'm pinging it from Centos 29
and it's working. If it’s working, go on, if it’s not, troubleshoot the network connectivity problem 30
and continue with ssh only when ping is working. 31
There are many ssh clients, putty and the open ssh client being the most used ones. In this lab 32
I’ll use the ssh command, which is the OpenSSH client program. On the client machine I'm running ssh 33
the user name student and the servers IP address. 34
The user name used for authentication should exist on the server, not on the client. 35
Keep this in mind! 36
The first time when a client is connecting to an ssh server, you'll see a message like this; the client 37
uses a cryptographic fingerprint to identify the server and prevent possible man in the middle attacks 38
in the future. 39
The host key is randomly generated when the ssh server is set up and is used to identify the server you 40
are connecting to. It will be saved on the client in a file called known_hosts in 41
.ssh directory in your user home directory and I am accepting it. 42
And I'm entering the password. 43
And it's working; I'm on the server and I can configure it. To disconnect from the server type exit or press 44
Ctrl + D 45
You can also specify the username that will authenticate on the server using the -l option like 46
this. 47
-l and the username, is the same. If you get any errors and cannot connect to the server, pose 48
this video and start the next one where I'll show you how to troubleshoot ssh connections. 49
Now, I'll suppose it's working and we'll go on. Let's see other useful options! 50
To connect to a port other than the default 22, to use the -p option in the port 51
number. I'm exiting the connection and I'm connecting again. 52
So -p and the part 22 in this case. 53
Note that the ssh client has its own configuration file, which is /etc/,ssh/ssh_config. 54
This is the configuration file of the client. 55
Normally, you don't change anything there, but you could, for example, specify another default port, 56
specify the encryption algorithm used, a default username and many more. 57
Now, at the end, I'll show you how to connect to the ssh server from Windows using Putty. 58
Putty is an open source and free application that must be installed; download and install it from 59
this link. 60
I've already done it. 61
This is putty! Then open putty write the IP address of the server 192.168.0.20 62
the port ,if it uses another one in the not the default 22, 63
give a name to the session and save it. 64
Later, when you want to connect to the server, just open the session using its name. 65
I'm searching for the saved session Ubuntu.20.04 and I'm opening it. 66
And it is asking for the user and the password, so student and the password. 67
And I'm on the server, on Ubuntu. 68
We'll take a short break and in the next lecture, I'll show you how to troubleshoot ssh.