Restarting the SSH server service applies daemon changes that cannot wait for a reboot. Because sshd is the access path for remote administration, test the configuration first and keep a working shell or console available until a new login succeeds.

On systemd Linux hosts, the packaged OpenSSH server unit is usually ssh.service on Debian and Ubuntu, while some distributions expose sshd.service. The systemctl restart action stops and starts the unit, and systemctl is-active confirms whether the daemon returned to the running state.

A restart is stronger than a reload and can interrupt new connection attempts while the listener is recreated. Use it after package upgrades, daemon failures, or configuration changes that a reload cannot apply; for routine configuration edits, run sshd -t before touching the service and verify a fresh login from a separate client afterwards.

Steps to restart the SSH server service:

  1. Open a terminal on the SSH server with an account that can use sudo.

    Keep an existing SSH session or console path open until the restart completes and a new login works.

  2. Identify the installed SSH service unit name.
    $ systemctl list-unit-files ssh.service sshd.service --no-pager
    UNIT FILE    STATE    PRESET
    ssh.service  disabled enabled
    sshd.service alias    -
    
    2 unit files listed.

    Use ssh in later commands when ssh.service is the real unit; use sshd when the host provides sshd.service as the real unit.

  3. Test the sshd configuration before restarting.
    $ sudo sshd -t

    No output means the active server configuration parsed successfully and the configured host keys passed the sanity check.
    Related: How to test SSH server configuration

  4. Restart the SSH service.
    $ sudo systemctl restart ssh

    Replace ssh with sshd if the unit discovery step showed sshd.service as the real unit.
    Related: How to manage the SSH server service with systemctl

  5. Confirm that the service returned to the active state.
    $ systemctl is-active ssh
    active

    On socket-activated Ubuntu systems, ssh.service can show disabled for boot enablement while ssh.socket keeps the listener available.

  6. Confirm that sshd is listening on the expected port.
    $ sudo ss --tcp --listen --numeric --processes 'sport = :22'
    State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
    LISTEN 0      4096         0.0.0.0:22        0.0.0.0:*    users:(("sshd",pid=220,fd=3),("systemd",pid=1,fd=51))
    LISTEN 0      4096            [::]:22           [::]:*    users:(("sshd",pid=220,fd=4),("systemd",pid=1,fd=53))

    Change :22 if the server listens on a custom Port value.

  7. Confirm a fresh SSH login from a separate client session.
    $ ssh user@host.example.net 'echo SSH service restarted'
    SSH service restarted