12 lines
546 B
Python
12 lines
546 B
Python
import paramiko
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('140.44.4.90', username='rancher', password='Katzir476!', timeout=10)
|
|
|
|
cmd = "echo Katzir476! | sudo -S sh -c 'export KUBECONFIG=/etc/rancher/rke2/rke2.yaml; /var/lib/rancher/rke2/bin/kubectl get vms -A; /var/lib/rancher/rke2/bin/kubectl get volumes.longhorn.io -n longhorn-system | head -n 10'"
|
|
stdin, stdout, stderr = c.exec_command(cmd)
|
|
print("STDOUT:\n" + stdout.read().decode())
|
|
print("STDERR:\n" + stderr.read().decode())
|
|
c.close()
|