38 lines
945 B
Python
38 lines
945 B
Python
import paramiko
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('160.187.143.253', username='root', password=';ur7n)LC1BQ;')
|
|
|
|
def r(cmd):
|
|
print(f"Executing: {cmd}")
|
|
try:
|
|
_, so, se = c.exec_command(cmd, timeout=30)
|
|
stdout = so.read().decode('utf-8', 'replace').strip()
|
|
stderr = se.read().decode('utf-8', 'replace').strip()
|
|
if stdout: print(f"STDOUT:\n{stdout}")
|
|
if stderr: print(f"STDERR:\n{stderr}")
|
|
return stdout
|
|
except Exception as e:
|
|
return str(e)
|
|
|
|
ghost_dirs = [
|
|
'/var/www/iam',
|
|
'/var/www/iam_old',
|
|
'/var/www/vc',
|
|
'/var/www/vc_old',
|
|
'/var/www/c',
|
|
'/var/www/c_old',
|
|
'/var/www/xcu-omni-relay_old'
|
|
]
|
|
|
|
for ghost in ghost_dirs:
|
|
# Double check it is not the active 'jumpa' directory
|
|
if '/jumpa/' not in ghost:
|
|
r(f"rm -rf {ghost}")
|
|
|
|
# List /var/www to verify
|
|
r("ls -la /var/www")
|
|
|
|
c.close()
|