Search Port lines in sshd drop-ins
Read-onlygrep -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.
← Back to overviewAll commands
Essential check 2 / 3
03 / FIELD NOTES
Find every Port line under sshd_config and sshd_config.d before you reload ssh.
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.
sshd_config has a new Port, and the daemon still listens on 22.
Open the new port in the firewall before you reload ssh, or you can lock yourself out.
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.
sudo /usr/sbin/sshd -T | grep '^port '
sudo ss -lntpExpect: sshd -T describes a new daemon using this configuration. Existing listeners can differ until reload; socket activation or service arguments can also change them.
Read-only. Keep the current SSH session open. Allow and test a new port before closing the existing connection.
{
"slug": "sshd-config-d",
"risk": "safe",
"tags": [
"ssh",
"sshd",
"port"
],
"updated": "2026-10-30",
"pathIndex": 2,
"why": "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.",
"steps": [
{
"command": "grep -R -n -E '^\\s*Port\\s+' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/",
"risk": "safe"
},
{
"command": "sudo /usr/sbin/sshd -T | grep '^port '\nsudo ss -lntp",
"risk": "safe"
}
]
}