-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
211 lines (182 loc) · 7.45 KB
/
Copy pathscript.sh
File metadata and controls
211 lines (182 loc) · 7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
# ============================================
# SSH Tunnel Account Creator
# For HTTP Custom / SSH Tunnel Apps
# Personal Use Only
# ============================================
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Get server info
SERVER_IP=$(curl -s ifconfig.me)
DOMAIN=$(hostname -d 2>/dev/null)
[ -z "$DOMAIN" ] && DOMAIN=$SERVER_IP
clear
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo -e "${GREEN} SSH TUNNEL ACCOUNT CREATOR v1.0 ${NC}"
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo ""
# ============================================
# Install Required Packages
# ============================================
echo -e "${YELLOW}[1/5] Installing SSH Server...${NC}"
apt-get update
apt-get install openssh-server dropbear stunnel4 wget curl -y
# ============================================
# Configure SSH on port 443 (for HTTP Custom)
# ============================================
echo -e "${YELLOW}[2/5] Configuring SSH on port 443...${NC}"
sed -i 's/#Port 22/Port 22\nPort 443/' /etc/ssh/sshd_config
systemctl restart sshd
# ============================================
# Configure Dropbear
# ============================================
echo -e "${YELLOW}[3/5] Configuring Dropbear...${NC}"
cat > /etc/default/dropbear << EOF
NO_START=0
DROPBEAR_PORT=222
DROPBEAR_EXTRA_ARGS="-p 80 -p 222"
EOF
systemctl restart dropbear
# ============================================
# Configure SSL/Stunnel
# ============================================
echo -e "${YELLOW}[4/5] Configuring SSL Tunnel...${NC}"
# Generate SSL certificate
openssl req -new -x509 -days 365 -nodes \
-out /etc/stunnel/stunnel.pem \
-keyout /etc/stunnel/stunnel.pem \
-subj "/C=US/ST=State/L=City/O=Organization/CN=$DOMAIN" 2>/dev/null
# Configure Stunnel
cat > /etc/stunnel/stunnel.conf << EOF
cert = /etc/stunnel/stunnel.pem
client = no
socket = a:SO_REUSEADDR=1
[ssh]
accept = 8443
connect = 127.0.0.1:443
EOF
# Enable Stunnel
sed -i 's/ENABLED=0/ENABLED=1/' /etc/default/stunnel4 2>/dev/null
systemctl restart stunnel4
# ============================================
# Function to create account
# ============================================
create_account() {
local username=$1
local password=$2
local expiry_days=$3
# Delete if exists
if id "$username" &>/dev/null; then
userdel -r "$username" 2>/dev/null
fi
# Create user (limited shell for security)
useradd -m -s /bin/false "$username"
echo "$username:$password" | chpasswd
# Set expiry
chage -E $(date -d "+$expiry_days days" +%Y-%m-%d) "$username" 2>/dev/null
# Format for HTTP Custom
FORMAT_443="${DOMAIN}:443@${username}:${password}"
FORMAT_80="${DOMAIN}:80@${username}:${password}"
FORMAT_SSL="${DOMAIN}:8443@${username}:${password}"
# Save to file
echo "$FORMAT_443" >> /root/ssh_accounts.txt
}
# ============================================
# Create Accounts
# ============================================
echo -e "${YELLOW}[5/5] Creating SSH Accounts...${NC}"
# Create main account
create_account "theguys" "1" 30
# Create extra accounts
create_account "user2" "pass123" 30
create_account "user3" "pass321" 30
create_account "tunnel" "tunnel1" 30
create_account "vpn" "vpnpass" 30
clear
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo -e "${GREEN} ✅ SETUP COMPLETE! ${NC}"
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo ""
echo -e "${YELLOW}📡 Server Information:${NC}"
echo -e " • Server IP: ${GREEN}$SERVER_IP${NC}"
echo -e " • Domain: ${GREEN}$DOMAIN${NC}"
echo -e " • SSH Port 443: ${GREEN}Active${NC}"
echo -e " • HTTP Port 80: ${GREEN}Active${NC}"
echo -e " • SSL Port 8443: ${GREEN}Active${NC}"
echo ""
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo -e "${GREEN}📱 HTTP Custom Account Format:${NC}"
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo ""
# Display accounts in format
echo -e "${YELLOW}👉 Account 1 (Main):${NC}"
echo -e " ${GREEN}${DOMAIN}:443@theguys:1${NC}"
echo ""
echo -e "${YELLOW}👉 Account 2:${NC}"
echo -e " ${GREEN}${DOMAIN}:443@user2:pass123${NC}"
echo ""
echo -e "${YELLOW}👉 Account 3:${NC}"
echo -e " ${GREEN}${DOMAIN}:443@user3:pass321${NC}"
echo ""
echo -e "${YELLOW}👉 Account 4:${NC}"
echo -e " ${GREEN}${DOMAIN}:80@tunnel:tunnel1${NC}"
echo ""
echo -e "${YELLOW}👉 Account 5:${NC}"
echo -e " ${GREEN}${DOMAIN}:8443@vpn:vpnpass${NC}"
echo ""
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo -e "${GREEN}🔧 HOW TO USE IN HTTP CUSTOM:${NC}"
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo ""
echo "1. Open ${GREEN}HTTP Custom${NC} app"
echo "2. Tap ${GREEN}+ Add Config${NC}"
echo "3. Paste: ${DOMAIN}:443@theguys:1"
echo "4. Enable ${GREEN}SSL${NC} if using port 443/8443"
echo "5. Tap ${GREEN}Connect${NC}"
echo ""
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo -e "${GREEN}📋 Useful Commands:${NC}"
echo -e "${BLUE}════════════════════════════════════════${NC}"
echo ""
echo "➕ ${YELLOW}Add new account:${NC}"
echo ' useradd -m -s /bin/false username && echo "username:pass" | chpasswd'
echo ""
echo "❌ ${YELLOW}Delete account:${NC}"
echo " userdel -r username"
echo ""
echo "📊 ${YELLOW}View all accounts:${NC}"
echo " cat /root/ssh_accounts.txt"
echo ""
echo "🔄 ${YELLOW}Restart SSH:${NC}"
echo " systemctl restart sshd"
echo ""
echo "🔌 ${YELLOW}Check active connections:${NC}"
echo " netstat -tunap | grep ESTABLISHED"
echo ""
# Save all accounts to file
cat > /root/HTTP_CUSTOM_ACCOUNTS.txt << EOF
════════════════════════════════════════
SSH TUNNEL ACCOUNTS
Created: $(date)
════════════════════════════════════════
Server: $DOMAIN
IP: $SERVER_IP
════════════════════════════════════════
📱 HTTP CUSTOM FORMAT:
1. $DOMAIN:443@theguys:1
2. $DOMAIN:443@user2:pass123
3. $DOMAIN:443@user3:pass321
4. $DOMAIN:80@tunnel:tunnel1
5. $DOMAIN:8443@vpn:vpnpass
════════════════════════════════════════
SSL ENABLED PORTS: 443, 8443
NO SSL PORT: 80
════════════════════════════════════════
EOF
echo -e "${GREEN}✅ Accounts saved to: /root/HTTP_CUSTOM_ACCOUNTS.txt${NC}"
echo -e "${GREEN}✅ Run 'cat /root/HTTP_CUSTOM_ACCOUNTS.txt' to view again${NC}"
echo ""