28 lines
1006 B
Python
28 lines
1006 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('140.44.4.27', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=8)
|
|
|
|
unstick_cmd = """
|
|
kill -9 3712358 3712345 3712344 3712307 3700051 2>/dev/null || true
|
|
echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections
|
|
echo "linux-base linux-base/removing-running-kernel boolean false" | debconf-set-selections
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
dpkg --configure -a
|
|
apt-get -f install -y
|
|
apt-get autoremove -y
|
|
"""
|
|
stdin, stdout, stderr = ssh.exec_command(unstick_cmd)
|
|
print("STDOUT:\n", stdout.read().decode())
|
|
print("STDERR:\n", stderr.read().decode())
|
|
|
|
stdin, stdout, stderr = ssh.exec_command("ps aux | grep -i apt; ps aux | grep -i dpkg; test -f /var/run/reboot-required && echo 'reboot required' || echo 'no reboot required'")
|
|
print("STATUS:\n", stdout.read().decode())
|
|
|
|
ssh.close()
|
|
|