![注释文件中的现有行并在 ksh shell 中的注释行下方添加 3 个新行](https://linux22.com/image/138272/%E6%B3%A8%E9%87%8A%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E7%8E%B0%E6%9C%89%E8%A1%8C%E5%B9%B6%E5%9C%A8%20ksh%20shell%20%E4%B8%AD%E7%9A%84%E6%B3%A8%E9%87%8A%E8%A1%8C%E4%B8%8B%E6%96%B9%E6%B7%BB%E5%8A%A0%203%20%E4%B8%AA%E6%96%B0%E8%A1%8C.png)
配置文件有以下行:
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
因此需要注释掉这一行并在注释行之后添加以下行。
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour
PubkeyAcceptedKeyTypes [email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa,ssh-dss
HostKeyAlgorithms [email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ssh-ed25519,ssh-rsa,ssh-dss
输出应采用以下格式。
#Ciphers aes128-ctr,aes192-ctr,aes256-ctr
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour
PubkeyAcceptedKeyTypes [email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa,ssh-dss
HostKeyAlgorithms [email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ssh-ed25519,ssh-rsa,ssh-dss
答案1
尝试
sed '/Ciphers aes128-ctr,aes192-ctr,aes256-ctr/ {s/^/#/; a\
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128cbc,3des-cbc,blowfish-cbc,cast128- . . .
}' file