Find a command/
中文
☰

← Back to overviewAll commands

Essential check 2 / 3

03 / FIELD NOTES

The SSH port that actually wins

Find every Port line under sshd_config and sshd_config.d before you reload ssh.

Read-onlysshsshdport

Why this way

Include directives and service startup options affect the configuration. Port permits multiple values, so do not assume a drop-in simply overrides the main file. Compare the effective configuration with actual listeners.

When to use

sshd_config has a new Port, and the daemon still listens on 22.

When not to

Open the new port in the firewall before you reload ssh, or you can lock yourself out.

Prerequisites

  • grep
  • read access to /etc/ssh

Steps

Search Port lines in sshd drop-ins

Read-only
grep -R -n -E '^\s*Port\s+' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/

Expect: Find declared ports. Check Include locations; multiple Port directives may coexist.

Inspect effective configuration and actual listeners

Read-only
sudo /usr/sbin/sshd -T | grep '^port '
sudo ss -lntp

Expect: sshd -T describes a new daemon using this configuration. Existing listeners can differ until reload; socket activation or service arguments can also change them.

What it changes

Read-only. Keep the current SSH session open. Allow and test a new port before closing the existing connection.

Next on the first-day path

Essential check 3 / 3Check services and listening portsList failed systemd units, listening ports, and recent errors.

← Previous: Know your server before changing it

Sources