import paramiko, time ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) cmd = 'kubectl run debug-21 --image=busybox --restart=Never --overrides=\'{"spec":{"nodeName":"sninfr2lnxwrk01","hostPID":true,"hostIPC":true,"hostNetwork":true,"containers":[{"name":"debug","image":"busybox","command":["nsenter","-t","1","-m","-u","-i","-n","-p","sh","-c","ls -la /root/.ssh; cat /root/.ssh/authorized_keys"],"securityContext":{"privileged":true}}]}}\'' stdin, stdout, stderr = ssh.exec_command(cmd) print('RUN:', stdout.read().decode()) print('RUN ERR:', stderr.read().decode()) time.sleep(6) stdin, stdout, stderr = ssh.exec_command('kubectl logs debug-21') print('LOGS:\n', stdout.read().decode()) ssh.exec_command('kubectl delete pod debug-21 --now') ssh.close()