Skip to content

Commit ebb1581

Browse files
committed
Add SSH tunnel user management TUI and fix slipnet:// tunnel types
- Add --users flag with interactive menu (list/add/change password/delete) - Fix slipnet:// tunnel type strings: ss, slipstream_ssh, dnstt_ssh - Fix corrupted grep ':53\b' line in step_free_port53 - Auto-installs sshtun-user if not present - Update README (English + Farsi) with user management docs
1 parent 6ad3326 commit ebb1581

2 files changed

Lines changed: 202 additions & 0 deletions

File tree

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Deploys [dnstm](https://github.com/net2share/dnstm) DNS tunnel servers with **Sl
1919
- [❓ In-TUI Help System](#-in-tui-help-system)
2020
- [📱 Client Apps](#-client-apps)
2121
- [🛠️ Management Commands](#️-management-commands)
22+
- [👤 SSH Tunnel User Management](#-ssh-tunnel-user-management)
2223
- [🗑️ Uninstall](#️-uninstall)
2324
- [📖 Manual Setup Guide](#-manual-setup-guide)
2425
- [🔧 Troubleshooting](#-troubleshooting)
@@ -340,6 +341,9 @@ sudo bash dnstm-setup.sh --mtu 1200
340341
# 🌐 Add a backup domain with custom MTU
341342
sudo bash dnstm-setup.sh --add-domain --mtu 1200
342343

344+
# 👤 Manage SSH tunnel users (add, list, update, delete)
345+
sudo bash dnstm-setup.sh --users
346+
343347
# 🗑️ Remove all installed components
344348
sudo bash dnstm-setup.sh --uninstall
345349

@@ -485,6 +489,30 @@ curl --socks5 127.0.0.1:<MICROSOCKS_PORT> https://api.ipify.org
485489

486490
---
487491

492+
## 👤 SSH Tunnel User Management
493+
494+
Manage SSH tunnel users after setup with the built-in user management TUI:
495+
496+
```bash
497+
sudo bash dnstm-setup.sh --users
498+
```
499+
500+
This opens an interactive menu:
501+
502+
| Option | Action |
503+
|---|---|
504+
| **1** | **List users** — show all SSH tunnel users |
505+
| **2** | **Add user** — create a new tunnel user (with password or auto-generated) |
506+
| **3** | **Change password** — update an existing user's password |
507+
| **4** | **Delete user** — remove a user (with confirmation) |
508+
| **0** | **Exit** |
509+
510+
> **What are SSH tunnel users?** These are restricted system users that can only create SSH tunnels (SOCKS proxy, port forwarding) — they have no shell access and cannot run commands on your server. They're required for the SSH-based tunnels (`s2` and `ds2` subdomains).
511+
512+
If `sshtun-user` is not installed, the script will automatically download and configure it on first run.
513+
514+
---
515+
488516
## 🗑️ Uninstall
489517

490518
To remove everything installed by this script:
@@ -740,6 +768,18 @@ sudo bash dnstm-setup.sh --add-domain
740768

741769
اگر یک دامنه مسدود شود، دامنه دیگر همچنان کار می‌کند.
742770

771+
### مدیریت کاربران SSH
772+
773+
بعد از نصب، می‌توانید کاربران تانل SSH رو مدیریت کنید:
774+
775+
</div>
776+
777+
```bash
778+
sudo bash dnstm-setup.sh --users
779+
```
780+
781+
<div dir="rtl">
782+
743783
---
744784

745785
## 🌍 تنظیمات DNS در Cloudflare
@@ -910,6 +950,34 @@ curl --socks5 127.0.0.1:<MICROSOCKS_PORT> https://api.ipify.org
910950

911951
---
912952

953+
## 👤 مدیریت کاربران SSH
954+
955+
بعد از نصب، کاربران تانل SSH رو با منوی مدیریتی مدیریت کنید:
956+
957+
</div>
958+
959+
```bash
960+
sudo bash dnstm-setup.sh --users
961+
```
962+
963+
<div dir="rtl">
964+
965+
این دستور یک منوی تعاملی باز می‌کند:
966+
967+
| گزینه | عملکرد |
968+
|---|---|
969+
| **1** | **لیست کاربران** — نمایش تمام کاربران تانل SSH |
970+
| **2** | **افزودن کاربر** — ساخت کاربر جدید (با رمز دستی یا خودکار) |
971+
| **3** | **تغییر رمز** — بروزرسانی رمز عبور یک کاربر |
972+
| **4** | **حذف کاربر** — حذف کاربر (با تأیید) |
973+
| **0** | **خروج** |
974+
975+
> **کاربران تانل SSH چی هستن؟** کاربران محدود سیستمی هستن که فقط می‌تونن تانل SSH بزنن (پروکسی SOCKS، فوروارد پورت) — دسترسی shell ندارن و نمی‌تونن روی سرور شما دستوری اجرا کنن. برای تانل‌های SSH (ساب‌دامین‌های `s2` و `ds2`) لازمن.
976+
977+
اگر `sshtun-user` نصب نباشد، اسکریپت خودکار آن را دانلود و تنظیم می‌کند.
978+
979+
---
980+
913981
## 🔧 عیب‌یابی
914982

915983
### 🔴 پورت 53 همچنان در استفاده است

dnstm-setup.sh

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ show_help() {
474474
echo " --help Show this help message"
475475
echo " --about Show project information and credits"
476476
echo " --add-domain Add another domain to an existing server (backup/fallback)"
477+
echo " --users Manage SSH tunnel users (add, list, update, delete)"
477478
echo " --mtu <value> Set DNSTT MTU size (512-1400, default: 1232)"
478479
echo " --harden Apply service and resolver hardening to an existing setup"
479480
echo " --uninstall Remove all installed components"
@@ -900,10 +901,137 @@ do_uninstall() {
900901
echo ""
901902
}
902903

904+
# ─── User Management TUI ──────────────────────────────────────────────────────
905+
906+
do_manage_users() {
907+
banner
908+
print_header "SSH Tunnel User Management"
909+
910+
# Check root
911+
if [[ $EUID -ne 0 ]]; then
912+
print_fail "Not running as root. Please run with: sudo bash $0 --users"
913+
exit 1
914+
fi
915+
916+
# Install sshtun-user if not present
917+
if ! command -v sshtun-user &>/dev/null; then
918+
print_info "sshtun-user not found. Installing..."
919+
if curl -fsSL -o /usr/local/bin/sshtun-user https://github.com/net2share/sshtun-user/releases/latest/download/sshtun-user-linux-amd64; then
920+
chmod +x /usr/local/bin/sshtun-user
921+
print_ok "Downloaded sshtun-user"
922+
else
923+
print_fail "Failed to download sshtun-user. Check your internet connection."
924+
exit 1
925+
fi
926+
927+
# Run initial configure
928+
print_info "Applying SSH security configuration..."
929+
sshtun-user configure 2>&1 || true
930+
print_ok "SSH configuration applied"
931+
echo ""
932+
fi
933+
934+
while true; do
935+
echo ""
936+
echo -e " ${BOLD}SSH Tunnel User Management${NC}"
937+
echo -e " ${DIM}────────────────────────────────────────${NC}"
938+
echo ""
939+
echo -e " ${BOLD}1${NC} List users"
940+
echo -e " ${BOLD}2${NC} Add user"
941+
echo -e " ${BOLD}3${NC} Change password"
942+
echo -e " ${BOLD}4${NC} Delete user"
943+
echo -e " ${BOLD}0${NC} Exit"
944+
echo ""
945+
946+
local choice
947+
read -rp " Select [0-4]: " choice
948+
949+
case "$choice" in
950+
1)
951+
echo ""
952+
print_info "SSH tunnel users:"
953+
echo ""
954+
sshtun-user list 2>&1 || print_warn "No users found or sshtun-user error"
955+
;;
956+
2)
957+
echo ""
958+
local new_user new_pass
959+
new_user=$(prompt_input "Enter username for new tunnel user")
960+
if [[ -z "$new_user" ]]; then
961+
print_fail "Username cannot be empty"
962+
continue
963+
fi
964+
new_pass=$(prompt_input "Enter password (leave blank to auto-generate)")
965+
echo ""
966+
if [[ -n "$new_pass" ]]; then
967+
if sshtun-user create "$new_user" --insecure-password "$new_pass" 2>&1; then
968+
print_ok "User '${new_user}' created"
969+
else
970+
print_fail "Failed to create user '${new_user}'"
971+
fi
972+
else
973+
if sshtun-user create "$new_user" 2>&1; then
974+
print_ok "User '${new_user}' created"
975+
else
976+
print_fail "Failed to create user '${new_user}'"
977+
fi
978+
fi
979+
;;
980+
3)
981+
echo ""
982+
local upd_user upd_pass
983+
upd_user=$(prompt_input "Enter username to update")
984+
if [[ -z "$upd_user" ]]; then
985+
print_fail "Username cannot be empty"
986+
continue
987+
fi
988+
upd_pass=$(prompt_input "Enter new password")
989+
if [[ -z "$upd_pass" ]]; then
990+
print_fail "Password cannot be empty"
991+
continue
992+
fi
993+
echo ""
994+
if sshtun-user update "$upd_user" --insecure-password "$upd_pass" 2>&1; then
995+
print_ok "Password updated for '${upd_user}'"
996+
else
997+
print_fail "Failed to update user '${upd_user}'"
998+
fi
999+
;;
1000+
4)
1001+
echo ""
1002+
local del_user
1003+
del_user=$(prompt_input "Enter username to delete")
1004+
if [[ -z "$del_user" ]]; then
1005+
print_fail "Username cannot be empty"
1006+
continue
1007+
fi
1008+
if prompt_yn "Are you sure you want to delete '${del_user}'?" "n"; then
1009+
if sshtun-user delete "$del_user" 2>&1; then
1010+
print_ok "User '${del_user}' deleted"
1011+
else
1012+
print_fail "Failed to delete user '${del_user}'"
1013+
fi
1014+
else
1015+
print_info "Cancelled"
1016+
fi
1017+
;;
1018+
0)
1019+
echo ""
1020+
print_ok "Done"
1021+
exit 0
1022+
;;
1023+
*)
1024+
print_warn "Invalid choice"
1025+
;;
1026+
esac
1027+
done
1028+
}
1029+
9031030
# ─── Parse Arguments ────────────────────────────────────────────────────────────
9041031

9051032
ADD_DOMAIN_MODE=false
9061033
HARDEN_ONLY_MODE=false
1034+
MANAGE_USERS_MODE=false
9071035
DNSTT_MTU=1232
9081036

9091037
while [[ $# -gt 0 ]]; do
@@ -924,6 +1052,10 @@ while [[ $# -gt 0 ]]; do
9241052
ADD_DOMAIN_MODE=true
9251053
shift
9261054
;;
1055+
--users)
1056+
MANAGE_USERS_MODE=true
1057+
shift
1058+
;;
9271059
--harden)
9281060
HARDEN_ONLY_MODE=true
9291061
shift
@@ -2279,6 +2411,8 @@ if [[ "$HARDEN_ONLY_MODE" == true ]]; then
22792411
do_harden
22802412
elif [[ "$ADD_DOMAIN_MODE" == true ]]; then
22812413
do_add_domain
2414+
elif [[ "$MANAGE_USERS_MODE" == true ]]; then
2415+
do_manage_users
22822416
else
22832417
main
22842418
fi

0 commit comments

Comments
 (0)