Skip to content

Instantly share code, notes, and snippets.

@soheilsec
Last active October 2, 2023 17:44
Show Gist options
  • Save soheilsec/ee4a27c30a1fced0484d21c25fbca026 to your computer and use it in GitHub Desktop.
Save soheilsec/ee4a27c30a1fced0484d21c25fbca026 to your computer and use it in GitHub Desktop.
Linux SSH VPN
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo -e "user $username exists!"
exit 1
fi
read -p "Enter expire date ( y-m-d ) example 2023-06-10 : " date
read -p "Enter traffic (GB) : " traffic
read -p "Enter password : " password
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p "$pass" "$username" --shell=/bin/false
usermod -e "$date" "$username"
prefix=1000000000
gb=$((traffic * prefix))
iptables -A OUTPUT -p tcp -m owner --uid-owner $username -m quota --quota $gb -j ACCEPT
[ $? -eq 0 ] && echo -e "user added :) "
echo -e "----------------------------------------------"
echo -e "username : "$username
echo -e "expiry date : "$date
echo -e "traffic (GB) : "$traffic
echo -e "password : "$password
echo -e "----------------------------------------------" || echo "Failed to add a user!"
else
echo "Only root may add a user to the system."
exit 2
fi
#!/bin/sh
OS=`uname -m`;
sudo wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/daybreakersx/premscript/master/badvpn-udpgw"
if [ "$OS" == "x86_64" ]; then
sudo wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/daybreakersx/premscript/master/badvpn-udpgw64"
fi
sudo touch /etc/rc.local
sudo echo "\nscreen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300" >> /etc/rc.local
sudo chmod +x /usr/bin/badvpn-udpgw
sudo screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300
برای تک کاربر کردن:
اول میام یوزر خودم میگم یکی بتونه وصل بشه
nano /etc/security/limits.conf
soheil - maxlogins 1
بعد تو تنظیمات تک session میکنم
nano /etc/ssh/sshd_config
MaxSessions 1
بعد سرویس ریستارت میکنم
اگر centos
service sshd restart
اگر ابونتو
service ssh restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment