sshd -T: Effective Config
When sshd_config changes don’t apply as expected, diagnosing without restarting the daemon can be costly. The sshd -T command displays the configuration that the OpenSSH daemon actually uses, based on current files and directives. This lets you verify the effectiveness of changes in real time without disrupting active sessions.
Checking the Active Config
Launching sshd -T without arguments prints key parameters in key value format. This includes negotiated ciphers, authentication methods, file paths, and other daemon settings. The result reflects the final configuration after all Match blocks and Include directives have been processed.
To view settings for a specific user or from a particular config file, use the -u and -f flags:
Output can be redirected to a file for comparison or to search for differences between configuration versions.
Main -T Flags
| Flag | Description |
|---|---|
-C директива | Оценивает значение конкретной директивы конфига. Полезно для проверки одной настройки без вывода всего списка. |
-O опция | Проверяет, является ли опция валидной для текущей версии sshd. Возвращает yes или no. |
-P опция | Проверяет, разрешена ли опция (не отключена AllowUsers, DenyGroups и аналогичными ограничениями). |
-f файл_конфига | Задает путь к файлу конфигурации вместо默认 /etc/ssh/sshd_config. |
-u пользователь | Симулирует проверку от имени указанного пользователя, что учитывает User-специфичные Match блоки. |
Флаг -C особенно важен при аудите: sshd -T -C "PasswordAuthentication no" покажет, примет ли демон это значение, и включит ли это другие связанные ограничения.
Examples Usage
Check if password authentication disable is active:
Output may contain the line password_authentication no, confirming the setting is applied. If the line is absent or reads yes, a Match block or Include may have overridden the value.
Verify validity of a new option before reload:
The -P flag checks whether the proposed option is permitted under current security policy:
A yes result means the option is enabled and not prohibited by global rules.
Common Errors
- Ignoring
Matchblocks. Changing a directive at the top of the file doesn’t guarantee application if a lowerMatch User adminblock sets its ownPasswordAuthentication yes. Always verifysshd -Toutput after such changes. - Confusing
-Oand-P.-Ochecks syntactic validity of the option, while-Pchecks whether the current config allows its use. Both are needed at different debugging stages. - Config path dependency. Running
sshd -Twithout-fuses the path compiled into the daemon (usually/etc/ssh/sshd_config). When using custom paths, ensure file permissions and ownership are correct, otherwise the daemon may ignore the file at startup. - Caching. After editing the config, remember to reload the daemon (
systemctl reload sshdorSIGHUPsignal), otherwisesshd -Twill show the old parameter set.
Automation Check
For regular config auditing, a simple script can compare sshd -T output against expected values or detect unexpected changes:
Such an approach is convenient to place in CI/CD pipelines or cron jobs for config control after deployment changes.