SSH Secure Shell

Secure Shell (“SSH”) is a tool used to access a shell on a remote device.

SSH overview

SSH uses a client/server model where one computer acts as an SSH server[^1] and allows other computers to connect.

Example SSH Client and Server

Connecting to an SSH Server

To access a device remotely, the ssh command is run from the shell, mostly used with this format:

ssh [username@]<server url>

If you don’t specify a username then SSH will attempt to connect you using the username with which you are logged in. Here are some examples:

  • ssh [email protected]
    • This will attempt to connect to the server at myserver.com using the username myuser
  • ssh [email protected]
    • This is just like the example above except you can also specify an IP address instead of a hostname
  • ssh myserver.com
    • This will attempt to connect to the SSH server at myserver.com using your current username

When using any of the above commands, once connected to the remote server you’ll be prompted for a password.

Running Your Own SSH Server

Start by installing the SSH server:

sudo dnf install openssh-server

Then start the server using:

systemctl enable --now sshd

You will be prompted to enter your password, enter it.

Once the above command is run, your machine will begin listening for incoming connections on port 22. You can verify that the SSH server application started correctly by using the command

systemctl status sshd

You should see output similar to this:

 sshd.service - OpenSSH server daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: enabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Sun 2024-04-07 14:00:20 EDT; 44min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 1065 (sshd)
      Tasks: 1 (limit: 4396)
     Memory: 156.0K
        CPU: 50ms
     CGroup: /system.slice/sshd.service
             └─1065 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Apr 07 14:00:20 ultramarine systemd[1]: Starting sshd.service - OpenSSH server daemon...
Apr 07 14:00:20 ultramarine sshd[1065]: Server listening on 0.0.0.0 port 22.
Apr 07 14:00:20 ultramarine sshd[1065]: Server listening on :: port 22.
Apr 07 14:00:20 ultramarine systemd[1]: Started sshd.service - OpenSSH server daemon.

Check for the field that says Active: active (running) to ensure that the SSH server is listening for incoming connections.

If you’d like to stop the SSH server, you can do so with

sudo systemctl stop sshd

You should see output similar to this:


 sshd.service - OpenSSH server daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: enabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: inactive (dead) since Sun 2024-04-07 14:50:24 EDT; 3s ago
   Duration: 50min 4.206s
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 1065 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 1065 (code=exited, status=0/SUCCESS)
        CPU: 58ms

Apr 07 14:50:24 ultramarine systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Apr 07 14:50:24 ultramarine sshd[1065]: Received signal 15; terminating.
Apr 07 14:50:24 ultramarine systemd[1]: sshd.service: Deactivated successfully.
Apr 07 14:50:24 ultramarine systemd[1]: Stopped sshd.service - OpenSSH server daemon.

← Back To: Software and Package Management

[^1]### A Note about the Word “Server” It’s common to hear the word “server” used but not understand exactly what is meant. Here are a couple examples of how “server” can be used:

  • It can refer to a physical machine somewhere
    • Ex: Our email server lost power over the weekend.
  • It can refer to a specific application running on one machine (or even a number of machines across the world!)
    • Ex: The SSH server is up so that users can connect.

In this guide we’ll try to make it clear to which we’re referring.

Next Up: Security and Privacy →

← Back To: The Shell