Installing OpenSSH server software on an Ubuntu Linux system

Learning that lasts. Online courses from $14.99
To set up an Ubuntu Linux system as a Secure Shell (SSH) server, you can take the following steps:
  1. Open a terminal window.
  2. In the terminal window, issue the command sudo apt-get install openssh-server.
  3. Enable and start the ssh server service by issuing the command sudo systemctl enable ssh --now. If you wish to enable the service, but not start it immediately, you can omit the --now at the end of the command, i.e., you can use sudo systemctl enable ssh and then later issue the command sudo systemctl start ssh to start the service.

You can verify that the SSH server service is running by issuing the command sudo systemctl status ssh. You should see "active (running)" in the output and at least one line stating "Server listening on" followed by "port 22".

$ sudo systemctl status ssh
 ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: e>
     Active: active (running) since Sun 2024-06-23 19:39:34 EDT; 14min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 33706 (sshd)
      Tasks: 1 (limit: 2209)
     Memory: 1.7M
        CPU: 32ms
     CGroup: /system.slice/ssh.service
             └─33706 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Jun 23 19:39:34 Aura systemd[1]: Starting OpenBSD Secure Shell server...
Jun 23 19:39:34 Aura sshd[33706]: Server listening on 0.0.0.0 port 22.
Jun 23 19:39:34 Aura sshd[33706]: Server listening on :: port 22.
Jun 23 19:39:34 Aura systemd[1]: Started OpenBSD Secure Shell server.
$

You can also verify that the system is listening for SSH connections on the default SSH port, TCP port 22, by issuing the command nestat -a | grep ssh. You should see 0.0.0.0:ssh followed by LISTEN in the output of the command if the system is listening for IPv4 connections and [::]:ssh if the system is listening for IPv6 SSH connections.

$ netstat -a | grep ssh
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
unix  2      [ ACC ]     STREAM     LISTENING     20023    /tmp/ssh-XXXXXXkmaXmv/agent.1330
unix  2      [ ACC ]     STREAM     LISTENING     17812    /run/user/1000/gnupg/S.gpg-agent.ssh
unix  2      [ ACC ]     STREAM     LISTENING     27031    /run/user/127/gnupg/S.gpg-agent.ssh
unix  2      [ ACC ]     STREAM     LISTENING     27253    /run/user/1000/keyring/ssh
$

You should then be able to establish SSH connections to the system. Note: if you have firewall software installed, though, you may need to create a firewall rule to allow inbound connections to TCP port 22, the default SSH port.