Create run.py
Browse files
run.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
# Install SSH server
|
| 5 |
+
os.system("apt update && apt install -y openssh-server unzip")
|
| 6 |
+
|
| 7 |
+
# Set password root
|
| 8 |
+
os.system("echo 'root:123456' | chpasswd")
|
| 9 |
+
|
| 10 |
+
# Izinkan login root via password
|
| 11 |
+
os.system("sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config")
|
| 12 |
+
os.system("sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config")
|
| 13 |
+
|
| 14 |
+
# Start SSH
|
| 15 |
+
os.system("service ssh start")
|
| 16 |
+
|
| 17 |
+
# Download & install ngrok
|
| 18 |
+
os.system("wget -O ngrok.zip https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.zip")
|
| 19 |
+
os.system("unzip ngrok.zip")
|
| 20 |
+
os.system("chmod +x ngrok")
|
| 21 |
+
|
| 22 |
+
# Masukkan auth token ngrok (WAJIB)
|
| 23 |
+
NGROK_TOKEN = "ISI_TOKEN_NGROK_KAMU"
|
| 24 |
+
os.system(f"./ngrok config add-authtoken {NGROK_TOKEN}")
|
| 25 |
+
|
| 26 |
+
# Jalankan tunnel TCP ke port 22 (SSH)
|
| 27 |
+
os.system("./ngrok tcp 22 &")
|
| 28 |
+
|
| 29 |
+
print("Tunggu 10 detik untuk link SSH...")
|
| 30 |
+
time.sleep(10)
|
| 31 |
+
|
| 32 |
+
# Ambil info tunnel
|
| 33 |
+
os.system("curl -s http://127.0.0.1:4040/api/tunnels")
|