大网数据广告活动
服务器运维问答

sshd doesn't read included config files at startup

· 52CE 我爱测

My /etc/ssh/sshd_config ends with this line: Include sshd_config.d/sftp_users.conf The contents of that file are not included, however. Including by absolute path or with a glob doesn't change anything. To convince myself that it…

问题原文

原帖链接 · jma · CC BY-SA 4.0

My /etc/ssh/sshd_config ends with this line:

Include sshd_config.d/sftp_users.conf

The contents of that file are not included, however. Including by absolute path or with a glob doesn't change anything.

To convince myself that it's really not being read, I strace'd sshd (output below). Definitely not being read. And yet support for Include is supposedly present since 7.3p1 and apparently committed on 1 Feb 2020 (prior to 31 Mar 2020).

Although I can put my included files in the main sshd_config, it is convenient to push customisations into sshd_config.d/*conf.

Any suggestions why this doesn't work?

This is an ubuntu 20.04 image, fwiw.

Update

Using the -ddd option to sshd,

/usr/sbin/sshd -ddd

I discovered that including with relative pathnames, which appeared to me to be spec'd to work, does not work. Changing to an absolute pathname reports that the config is now being read:

debug2: /etc/ssh/sshd_config line 9: new include /etc/ssh/sshd_config.d/sftp_users.conf
debug2: /etc/ssh/sshd_config line 9: including /etc/ssh/sshd_config.d/sftp_users.conf
debug2: load_server_config: filename /etc/ssh/sshd_config.d/sftp_users.conf
debug2: load_server_config: done config len = 182
debug2: parse_server_config_depth: config /etc/ssh/sshd_config.d/sftp_users.conf len 182
debug3: checking syntax for 'Match Group sftp_users'

but the pattern never matches, whereas it does match if the Match block is in sshd_config itself.

社区高分解答

原帖链接 · jetboy · CC BY-SA 4.0

Something seems off. My fresh install of 20.04.2 LTS Server has a /etc/ssh/sshd_config

Include /etc/ssh/sshd_config.d/*.conf

That includes .conf files successfully. It's been the same for every version of LTS Server I've used. I can't comment on other images.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-03-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。