ITPub博客

首页 > > Linux操作系统 > [20180504]检查sshd配置是否正确.txt

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

原创 Linux操作系统 作者:lfree 时间:2018-05-04 10:33:55 0 删除 编辑

[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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2153801/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7971413