sed
で変更した内容を diff -u
に流して tee で標準エラーに出力しつつ path
にパイプします。
sed -r '
/^#*PermitRootLogin /cPermitRootLogin without-password
/^#*UseDNS /cUseDNS no
' /etc/ssh/sshd_config |
diff -u /etc/ssh/sshd_config - |
tee /dev/stderr |
patch /etc/ssh/sshd_config
次のように変更内容が Unified 形式の diff で出力されつつ patch
で適用されます。
--- /etc/ssh/sshd_config 2015-10-06 14:19:17.090000000 +0000
+++ - 2016-02-06 08:11:40.487720319 +0000
@@ -46,7 +46,7 @@
# Authentication:
#LoginGraceTime 2m
-#PermitRootLogin yes
+PermitRootLogin without-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
@@ -126,7 +126,7 @@
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
-#UseDNS yes
+UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
patching file /etc/ssh/sshd_config