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

简介: [20180504]检查sshd配置是否正确.txt --//有时候要修改sshd配置文件,有可能改错,如果这个时候远程重启sshd,可能导致无法再远程登录, --//必须有一种机制在重启前检查sshd的配置是否正确.

[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

目录
相关文章
|
数据安全/隐私保护 Perl
sshpass-如何在脚本中执行scp时自动输入密码
sshpass-如何在脚本中执行scp时自动输入密码
155 0
|
安全 Linux 网络安全
SSH远程登陆配置sshd_config文件详解
ssh是linux远程登录的安全协议,是 C/S 模式的架构,配置文件分为服务器端配置文件 [/etc/ssh/sshd_config] 与客户端配置文件默认配置文件[/etc/ssh/ssh_config] 用户配置文件[~/.ssh/config] sshd_config 是服务端主配置文件。
|
安全 Java Linux
sshpass 命令踩坑记录--未获取环境变量
sshpass 命令踩坑记录--未获取环境变量
314 0
|
算法 网络协议 安全
|
网络协议 网络安全
|
弹性计算 监控 Ubuntu
Ubuntu的SSH安全配置,查看SSH登录日志文件,修改默认端口,UFW配置防火墙,禁止root用户登录,禁用密码登陆,使用RSA私钥登录,使用 Fail2ban 工具,使用两步验证(2FA)
Ubuntu的SSH安全配置,查看SSH登录日志文件,修改默认端口,UFW配置防火墙,禁止root用户登录,禁用密码登陆,使用RSA私钥登录,使用 Fail2ban 工具,使用两步验证(2FA)
2434 0
|
Linux 数据库 Windows