【发布时间】:2016-07-24 04:11:33
【问题描述】:
我编写了一个 shell 脚本以在 /etc/ssh/sshd_config 中将 GSSAPIAuthentication 设置为 no。
在我的脚本中,我有这个部分:
if [ $( grep "^GSSAPIAuthentication no$" /etc/ssh/sshd_config >/dev/null; echo $? ) -ne 0 ]; then
sed -i 's/^[#]*GSSAPIAuthentication.*$/GSSAPIAuthentication no/g' /etc/ssh/sshd_config
fi
这很好用,但它会将所有出现的情况替换为:
#GSSAPIAuthentication no --> GSSAPIAuthentication no
#GSSAPIAuthentication 是 --> GSSAPIAuthentication 否
GSSAPIAuthentication 是 --> GSSAPIAuthentication 否
所以我有多行 GSSAPIAuthentication 没有。如何将其更改为只有一行 GSSAPIAuthentication no?
谢谢。
【问题讨论】: