Is /etc/ssh/sshd_config supporting inline comments and multiple key / value within the same line?

时间:2017-08-04 12:51:00

标签: bash unix sshd

I've to write an small script to modify /etc/ssh/sshd_config if this file is not matching with my checklist.

For examples I've to check below entries are matched, if not I need to replace with below entires:

Banner  /etc/motd  
GatewayPorts no   
KeyRegenerationInterval 3600  
LoginGraceTime 120  
LogLevel INFO    
PermitEmptyPasswords No    
PermitRootLogin No  
  1. Is /etc/ssh/sshd_config will be always like: One entry in a line like above or can it be any uses delimiter (Banner /etc/motd, GatewayPorts no)?
  2. Can comments can be anywhere in line (like C programming) or it should start at beginning of the line with #?

2 个答案:

答案 0 :(得分:1)

给出了部分答案,但没有回答所有问题,所以:

sshd_config(5)

  

sshd(8)从/ etc / ssh / sshd_config(或者)中读取配置数据   在命令行上使用-f指定的文件)。 该文件包含   关键字 - 参数对,每行一个以“#”和开头的行   空行被解释为注释。参数可以是可选的   用双引号(“)括起来表示参数   包含空格。

  1. 是的,它总是像KeyWord: value而永远不会KeyWord1: value1, KeyWord2: value2。 (该文件包含关键字 - 参数对,每行一个
  2. 看起来是的,它支持内联注释,即使没有人明确这个(所以,你可以避免它)。您可以运行sshd -T来验证您的配置并查看其运行情况。

答案 1 :(得分:0)

From the sshd_config(5) man page (emphasis mine):

The file contains keyword-argument pairs, one per line. Lines starting with ‘#’ and empty lines are interpreted as comments.