Der Titel des Posts sagt eigentlich schon alles 😉
Python 3:
#!/usr/bin/env python3 import fileinput import re file = fileinput.FileInput("/etc/ssh/sshd_config", inplace=True, backup=".bak") for line in file: line = re.sub(r".*Banner.*","Banner /etc/issue.net", line) print(line, end='') file.close()
Python 2:
#!/usr/bin/env python import fileinput import re import sys file = fileinput.FileInput("/etc/ssh/sshd_config", inplace=True, backup=".bak") for line in file: line = re.sub(r".*Banner.*","Banner /etc/issue.net", line) sys.stdout.write(line) file.close()