Skip to content

SSH server#

Before we can SSH to our server, we must make sure the SSH server is running. We can use systemctl to check this: systemctl status ssh

1
2
3
4
5
6
~$ systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
    Drop-In: /usr/lib/systemd/system/ssh.service.d
             └─ec2-instance-connect.conf
     Active: active (running) since Sun 2022-04-03 22:26:53 UTC; 1h 27min ago

I have it running on my Ubuntu Server in AWS. This is somewhat obvious to me, however, as I had to SSH in to run the above command. If you've been using the Ubuntu Server VM we created several chapters ago, then your installation should also have an active "OpenBSD Secure Shell Server" installation running. If it doesn't, follow the instructions below to install it.

Note

If you do have SSH running, you can skip these instructions.

Installing OpenSSH#

Start by installing the package: sudo apt install openssh-server.

Once that has finished installing, start and enable the service: sudo systemctl start ssh and sudo systemctl enable ssh.

Now check that you have SSH running: systemctl status ssh. You should see an active, running SSH server. It'll be listening on port TCP/22. We can check that, can't we? Because we've explored network monitoring tools previously: sudo lsof -i TCP:22

1
2
3
4
~$ sudo lsof -i TCP:22
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd    1807   root    3u  IPv4  26066      0t0  TCP *:ssh (LISTEN)
sshd    1807   root    4u  IPv6  26077      0t0  TCP *:ssh (LISTEN)

And just like that, we have SSH running.