Start some simple python admin scripts.

This commit is contained in:
James Grogan 2024-03-29 12:06:44 +00:00
parent 48587fe6e3
commit d1b91a0a89
11 changed files with 198 additions and 7 deletions

View file

@ -0,0 +1,25 @@
from pathlib import Path
import logging
from util import run_op
class SshConfig:
def __init__(self):
self.config_path = Path("/etc/ssh/ssh_config")
self.target_values = {"PermitRootLogin": "No",
"PasswordAuthentication": "No",
"ChallengeResponseAuthentication": "No",
"UsePAM": "No"}
def sync_target_values(self):
logging.info(f"Updating ssh config in: {self.config_path}")
pass
def restart_service(self):
op = "systemctl restart ssh"
logging.info(f"Restarting ssh service: {op}")
run_op(op)
def copy_ssh_dir_to_user(self, username:str):
op = f"rsync --archive --chown={username}:{username} ~/.ssh /home/{username}"