import os, paramiko host="192.168.0.104"; user="root"; pw=os.environ["XEN_PW"] c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(host, username=user, password=pw, timeout=20, disabled_algorithms={'pubkeys': ['rsa-sha2-256','rsa-sha2-512']}, look_for_keys=False, allow_agent=False) def run(cmd): i,o,e=c.exec_command(cmd,timeout=60); return (o.read().decode(errors="replace")+e.read().decode(errors="replace")).strip() # Generate a temporary XenAPI session ref for the HTTP export (avoids putting root pw in the RMM command log) pyc = ( "import XenAPI;" "s=XenAPI.Session('https://localhost');" "s.login_with_password('root', __import__('os').environ['XPW'], '1.0', 'g-migration');" "print(s._session)" ) out=run(f"XPW='{pw}' python -c \"{pyc}\"") print("SESSION_REF:", out) c.close()