27 lines
903 B
Python
27 lines
903 B
Python
import paramiko
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('161.97.93.156', username='carlos', password='Innova1978+*?')
|
|
|
|
stdin, stdout, stderr = ssh.exec_command('docker ps --format "{{.Names}}"')
|
|
names = stdout.read().decode('utf-8').strip().splitlines()
|
|
print("All running containers on VPS:")
|
|
for n in names:
|
|
print(" ", n)
|
|
|
|
for n in names:
|
|
stdin, stdout, stderr = ssh.exec_command(f'docker inspect {n} --format "{{{{json .Config.Env}}}}"')
|
|
env_str = stdout.read().decode('utf-8')
|
|
import json
|
|
try:
|
|
envs = json.loads(env_str)
|
|
auth_keys = [e for e in envs if 'API_KEY' in e or 'KEY' in e or 'TOKEN' in e or 'AUTHENTICATION' in e]
|
|
print(f"Container {n} relevant envs:")
|
|
for k in auth_keys:
|
|
print(" ", k)
|
|
except Exception as e:
|
|
print("Error parsing env:", e)
|
|
|
|
ssh.close()
|