Ver código fonte

Add support for ssh identity file in command line

jherve 1 mês atrás
pai
commit
fecb007e2e
2 arquivos alterados com 10 adições e 0 exclusões
  1. 1 0
      data/borgmatic.d/config.yaml
  2. 9 0
      start.py

+ 1 - 0
data/borgmatic.d/config.yaml

@@ -5,6 +5,7 @@ repositories:
 
 one_file_system: true
 remote_path: borg-1.4
+ssh_command: ssh -i ~/.ssh/${SSH_KEY_NAME}
 
 encryption_passphrase: "{credential file /credentials/borg_passphrase}"
 compression: lz4

+ 9 - 0
start.py

@@ -3,6 +3,7 @@ import subprocess
 import socket
 from pathlib import Path
 
+is_windows = os.name == "nt"
 
 data_sources = [
     Path.home() / "Documents" / "cv",
@@ -29,6 +30,12 @@ def main():
     ]
     if ssh_auth_sock:
         volumes += [f"{ssh_auth_sock}:{ssh_auth_sock}:Z"]
+
+    if is_windows:
+        ssh_key_name = "theenglishway-windows"
+    else:
+        ssh_key_name = "theenglishway.pub"
+
     volumes += [
         f"{vol}:/mnt/source{vol}:ro" for vol in data_sources
     ]
@@ -46,6 +53,8 @@ def main():
         container_name,
         "-e SSH_AUTH_SOCK",
         "-e TZ=Europe/Paris",
+        "-e",
+        f"SSH_KEY_NAME={ssh_key_name}",
         "--security-opt=label=disable"
     ] + volume_args + [image_name]
     print(args)