Add get and pdate function for ssh file
This commit is contained in:
@@ -38,6 +38,7 @@ class Collection:
|
|||||||
self.collection_name = collection_name
|
self.collection_name = collection_name
|
||||||
self.collection_path = Path.home().joinpath(".sshkeymanager", self.collection_name)
|
self.collection_path = Path.home().joinpath(".sshkeymanager", self.collection_name)
|
||||||
self.encryptor = Encryptor(password)
|
self.encryptor = Encryptor(password)
|
||||||
|
self.get_ssh_config_file()
|
||||||
|
|
||||||
def generate_ssh_key(self, name: str, key_type: str, passphrase: str| None = None):
|
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()
|
public_key = public_file.read()
|
||||||
|
|
||||||
return SshKey(name=name, key_type=key_type, private=private_key, public=public_key)
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user