我正在编写脚本来修改Ubuntu服务器上的设置。
我有以下几行:
sudo sed 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
问题在于更改将不会保留。它只是将“否”改回“是”。
当命令执行时,修改后的文件立即显示在终端上,显示“否”,但是当我整理文件或在vim中打开文件时,它再次显示“是”。
另外,我可以在vim中打开sshd_config并手动对其进行修改,所做的更改仍然很好。
有什么想法吗?
谢谢。
只需使用-i
开关启动命令
sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
从 man sed
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied).
The default operation mode is to break symbolic and hard links.
This can be changed with --follow-symlinks and --copy.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句