Download app.py from userrein/Python: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/spaces/userrein/Python/resolve/main/app.py
- Command line
-
hf download hf://spaces/userrein/Python/app.py
-
curl -L -o app.py https://huggingface.co/spaces/userrein/Python/resolve/main/app.py
2.06 kB
| import os | |
| import time | |
| import json | |
| import urllib.request | |
| # ========================= | |
| # INSTALL SSH | |
| # ========================= | |
| os.system("apt update -y") | |
| os.system("apt install -y openssh-server unzip curl wget") | |
| # ========================= | |
| # SET PASSWORD ROOT | |
| # ========================= | |
| os.system("echo 'root:123456' | chpasswd") | |
| # ========================= | |
| # KONFIGURASI SSH | |
| # ========================= | |
| os.system("sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config") | |
| os.system("sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config") | |
| # ========================= | |
| # START SSH | |
| # ========================= | |
| os.system("service ssh restart") | |
| # ========================= | |
| # INSTALL NGROK | |
| # ========================= | |
| os.system("wget -q -O ngrok.zip https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.zip") | |
| os.system("unzip -o ngrok.zip") | |
| os.system("chmod +x ngrok") | |
| # ========================= | |
| # MASUKKAN TOKEN NGROK | |
| # ========================= | |
| NGROK_TOKEN = "3C0LPg1zjf8Ui52LQnfPnD8RYAp_Y8Ps2ghwf2yCNvhL7vit" | |
| os.system(f"./ngrok config add-authtoken {NGROK_TOKEN}") | |
| # ========================= | |
| # JALANKAN NGROK | |
| # ========================= | |
| os.system("./ngrok tcp 22 > /dev/null 2>&1 &") | |
| print("⏳ Menunggu ngrok... (10 detik)") | |
| time.sleep(10) | |
| # ========================= | |
| # AMBIL LINK NGROK | |
| # ========================= | |
| try: | |
| with urllib.request.urlopen("http://127.0.0.1:4040/api/tunnels") as response: | |
| data = json.loads(response.read()) | |
| public_url = data['tunnels'][0]['public_url'] | |
| print("\n==============================") | |
| print("🔥 SSH AKTIF 🔥") | |
| print("Host:", public_url.replace("tcp://", "").split(":")[0]) | |
| print("Port:", public_url.split(":")[-1]) | |
| print("User: root") | |
| print("Pass: 123456") | |
| print("==============================\n") | |
| except: | |
| print("❌ Gagal ambil URL ngrok") | |
| # ========================= | |
| # LOOP AGAR TIDAK MATI | |
| # ========================= | |
| while True: | |
| time.sleep(60) |