Start some simple python admin scripts.
This commit is contained in:
parent
48587fe6e3
commit
d1b91a0a89
11 changed files with 198 additions and 7 deletions
25
machine_admin/ssh_config.py
Normal file
25
machine_admin/ssh_config.py
Normal 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}"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue