36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import paramiko
|
|
import time
|
|
|
|
SERVER_HOST = "172.17.0.253"
|
|
SERVER_USER = "itguys"
|
|
PASSWORD = "vR7Ag$Pk"
|
|
|
|
def verify():
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(SERVER_HOST, username=SERVER_USER, password=PASSWORD)
|
|
|
|
with open("logs/verify_logs.txt", "w", encoding="utf-8") as f:
|
|
f.write("--- Server Date ---\n")
|
|
cmd = f"echo '{PASSWORD}' | sudo -S date"
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
f.write(stdout.read().decode())
|
|
|
|
f.write("\n--- Generating Request ---\n")
|
|
cmd = "curl -v -k -I https://127.0.0.1/robots.txt"
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
f.write(stdout.read().decode())
|
|
f.write(stderr.read().decode())
|
|
|
|
time.sleep(2)
|
|
|
|
f.write("\n--- Latest Log Entries ---\n")
|
|
cmd = f"echo '{PASSWORD}' | sudo -S tail -n 2 /var/log/nginx/access_json.log"
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
f.write(stdout.read().decode())
|
|
|
|
client.close()
|
|
|
|
if __name__ == "__main__":
|
|
verify()
|