亲测有效 centos 一键修改sshd默认配置

一行代码实现,修改 ClientAliveInterval 为600,ClientAliveCountMax 为10,并重启sshd

如果是注释状态也需要解除注释并设置:

sed -i -e 's/^#ClientAliveInterval.*/ClientAliveInterval 3600/' \
       -e 's/^ClientAliveInterval.*/ClientAliveInterval 3600/' /etc/ssh/sshd_config && \
sed -i -e 's/^#ClientAliveCountMax.*/ClientAliveCountMax 16/' \
       -e 's/^ClientAliveCountMax.*/ClientAliveCountMax 16/' /etc/ssh/sshd_config && \
systemctl restart sshd

posted @ 2024-11-19 11:53  爱上编程技术  阅读(18)  评论(0)    收藏  举报  来源