From 6fb4aa65abdf07c7047b6e3c60125fa2bbc5ea86 Mon Sep 17 00:00:00 2001 From: jrenaud Date: Sun, 19 Oct 2025 19:16:58 +0200 Subject: [PATCH] Add get and pdate function for ssh file --- src/collection.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/collection.py b/src/collection.py index 2c7202b..b302d13 100644 --- a/src/collection.py +++ b/src/collection.py @@ -38,6 +38,7 @@ class Collection: self.collection_name = collection_name self.collection_path = Path.home().joinpath(".sshkeymanager", self.collection_name) self.encryptor = Encryptor(password) + self.get_ssh_config_file() def generate_ssh_key(self, name: str, key_type: str, passphrase: str| None = None): """ @@ -110,3 +111,18 @@ class Collection: public_key = public_file.read() return SshKey(name=name, key_type=key_type, private=private_key, public=public_key) + + def get_ssh_config_file(self): + """ + Function to get the content of the ssh_config file for the collection + """ + with open(self.collection_path.joinpath("ssh_config"), "r", encoding="utf-8") as config_file: + self.ssh_config = yaml.safe_load(config_file) + return self.ssh_config + + def update_ssh_config_file(self, content): + """ + Function to update the content of the ssh_config file for the collection + """ + with open(self.collection_path.joinpath("ssh_config"), "w+", encoding="utf-8") as config_file: + yaml.dump(content, config_file)