[20180504]检查sshd配置是否正确.txt

[20180504]检查sshd配置是否正确.txt

--//有时候要修改sshd配置文件,有可能改错,如果这个时候远程重启sshd,可能导致无法再远程登录,
--//必须有一种机制在重启前检查sshd的配置是否正确.查看man sshd文档,可以发现-t参数可以实现
--//这个需求.

-t Test mode. 
   Only check the validity of the configuration file and sanity of the keys.  This is useful for updating sshd reliably
   as configuration options may change.

--//测试如下:
# sshd -t
sshd re-exec requires execution with an absolute path

--//要使用全路径.
# which sshd
/usr/sbin/sshd

# /usr/sbin/sshd -t
--//OK!!

--//假设修改/etc/ssh/sshd_config,UseDNS no1

# grep -i dns /etc/ssh/sshd_config
UseDNS no1
#UseDNS yes

# /usr/sbin/sshd -t
/etc/ssh/sshd_config line 109: Bad yes/no argument: no1

--//可以发现配置提示错误行号.

# grep -ni dns /etc/ssh/sshd_config
109:UseDNS no1
110:#UseDNS yes

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值