Parcourir la source

ssh-Befehle werden remote als root ausgeführt

Markus Spring il y a 1 an
Parent
commit
9227e84367
1 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 5 3
      helpers/update_backup_copy_stats.py

+ 5 - 3
helpers/update_backup_copy_stats.py

@@ -27,7 +27,8 @@ müssen für springm beschreibbar sein
 '''
 
 # ------------------------------------------- start script variables ---
-remotehost      = 'r-hermes'
+remotehost      = 'hermes'
+ssh_username    = 'root'
 remoterepo      = '/backupdisk/backupdisk/restic-repo'
 json_remotefile = '/var/lib/restic/backupcopies.json'
 json_localfile  = '/tmp/backupcopies.json'
@@ -123,7 +124,8 @@ def write_json():
         print(f"Error: could not copy {json_localfile} to {remotehost}:{json_remotefile}")
 
 def rewrite_snapshots_json(host):
-    cmd = [ 'ssh', host, 'bash', '-c', "/usr/local/sbin/restic_json.sh" ]
+    cmd = [ 'ssh', f"""{ssh_username}@{host}""", 'bash', '-c', "/usr/local/sbin/restic_json.sh" ]
+    print(cmd)
     s = subprocess.check_output( cmd ).decode('utf-8').strip().split(' ')
     print(" ".join(s))
 
@@ -139,7 +141,7 @@ args = parser.parse_args()
 
 ssh = SSHClient()
 ssh.load_system_host_keys()
-ssh.connect(remotehost)
+ssh.connect(remotehost, username=ssh_username)
 
 load_jsonfile()
 update_json()