Skip to content

Instantly share code, notes, and snippets.

@AyushSachdev
Last active June 25, 2018 09:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save AyushSachdev/edc23605438f1cccdd50 to your computer and use it in GitHub Desktop.
Save AyushSachdev/edc23605438f1cccdd50 to your computer and use it in GitHub Desktop.
A shell script to install VPN using SoftEther and Transmission CLI Torrent Client on Ubuntu 14.04 for use on Digital Ocean

Readme

A shell script to install VPN using SoftEther and Transmission CLI Torrent Client on Ubuntu 14.04 for use on Digital Ocean

Execution

  • Execution for installation and setup
sudo su
wget ayush.sachdev.me/DigitalOceanVPN
sh DigitalVPN
  • Once the script starts running, follow the prompts. At

Setup VPN Softether manually now

  • Press 3 and type check

  • If all goes well, type quit

  • Press 1 to select "Management of VPN Server or VPN Bridge"

  • Press Enter without typing anything to connect to the localhost server

  • Again press Enter without inputting anything to connect to server by server admin mode.

  • Then use command below to change admin password ServerPasswordSet

  • Create a Virtual Hub named VPN using the command HubCreate VPN

  • Next you will be asked to enter an administrator password for the hub. This password will be used whenever you are not logged in as server admin mode, and you want to manage that specific hub.

  • Now select the Virtual Hub you created using this command Hub VPN

  • Enable SecureNAT using SecureNatEnable

  • Create a user named Ayush using the command UserCreate ayush

  • To set a password for Ayush, type UserPasswordSet ayush

  • To enable IPsecEnable type IPsecEnable

  • Enable L2TP over IPsec Server Function: Choose yes to enable L2TP VPN over IPSec with pre-shared key encryption. Now you can make VPN connections to this server using iPhone, Android, Windows, and Mac OS X devices.

  • Enable Raw L2TP Server Function: This will enable L2TP VPN for clients with no IPSec encryption.

  • Enable EtherIP / L2TPv3 over IPsec Server Function: Routers which are compatible with EtherIP / L2TPv3 over IPsec can connect to this server by enabling this function.

  • Pre Shared Key for IPsec: Enter a pre-shared key to use with L2TP VPN.

  • Default Virtual HUB in a case of omitting the HUB on the Username: Users must specify the Virtual Hub they are trying to connect to by using Username@TargetHubName as their username when connecting. This option specifies which Virtual Hub to be used if the user does not provide such information. In our case enter VPN.

  • Get Fully Qualified Domain Name (FQDN) using hostname -f

  • Generate a server for SSL using ServerCertRegenerate [FQDN]

  • Export the SSL certificate using ServerCertGet ~/cert.cer

  • Enable SSTP using SstpEnable yes

  • Enable OpenVPN using OpenVpnEnable yes /PORTS:1194

  • Export OpenVPN config using OpenVpnMakeConfig ~/my_openvpn_config.zip

  • Copy the link shown and enter the password

  • Hit control-C to stop dropbox sync: ^C

  • You can use dropbox.py help to control the Dropbox sync

# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/www;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
# ssl_prefer_server_ciphers on;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
autoindex on;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "/usr/share/nginx/www/downloads",
"download-limit": 100,
"download-limit-enabled": 0,
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/home/debian-transmission/Downloads",
"incomplete-dir-enabled": false,
"lpd-enabled": false,
"max-peers-global": 200,
"message-level": 2,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 200,
"peer-limit-per-torrent": 50,
"peer-port": 51413,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": false,
"preallocation": 1,
"prefetch-enabled": 1,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": false,
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-password": "{91cf1eea8281c75ef83302f6ed093ee707c82023lPsm1a/9",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "transmission",
"rpc-whitelist": "127.0.0.1",
"rpc-whitelist-enabled": false,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 18,
"upload-limit": 100,
"upload-limit-enabled": 0,
"upload-slots-per-torrent": 14,
"utp-enabled": true,
"watch-dir": "/usr/share/nginx/www/torrents",
"watch-dir-enabled": true
}
#!/bin/sh
# VPN and Torrent on Ubuntu 14.04 on Digital Ocean
# References:
# Torrent - https://gist.github.com/timothyandrew/6162351
# Torrent - http://filesharefreak.com/2012/05/10/seedbox-from-scratch-new-server-to-seeding-in-less-than-5-minutes
# VPN - https://www.digitalocean.com/community/articles/how-to-setup-a-multi-protocol-vpn-server-using-softether
DIR="`pwd`"
apt-get update -y && apt-get upgrade -y
apt-get dist-upgrade -y
apt-get -y install python-software-properties vim
add-apt-repository -y ppa:transmissionbt/ppa
apt-get -y update
apt-get -y install transmission-cli transmission-common transmission-daemon nginx
# nano /etc/transmission-daemon/settings.json
# "download-dir": "/etc/share/ngninx/www"
# "rpc-authentication-required": false
# "rpc-whitelist-enabled": false
mkdir -p /usr/share/nginx/www
mkdir -p /usr/share/nginx/www/downloads
mkdir -p /usr/share/nginx/www/torrents
chmod -R 777 /usr/share/nginx/www
rm -f /usr/share/nginx/www/index.html
wget https://gist.githubusercontent.com/AyushSachdev/edc23605438f1cccdd50/raw/settings.json
mv $DIR/settings.json /etc/transmission-daemon/settings.json
wget https://gist.githubusercontent.com/AyushSachdev/edc23605438f1cccdd50/raw/nginx.conf
mv $DIR/nginx.conf /etc/nginx/nginx.conf
wget https://gist.githubusercontent.com/AyushSachdev/edc23605438f1cccdd50/raw/default-site
mv $DIR/default-site /etc/nginx/sites-enabled/default
/etc/init.d/transmission-daemon reload
/etc/init.d/nginx restart
wget http://www.softether-download.com/files/softether/v4.07-9448-rtm-2014.06.06-tree/Linux/SoftEther%20VPN%20Server/64bit%20-%20Intel%20x64%20or%20AMD64/softether-vpnserver-v4.07-9448-rtm-2014.06.06-linux-x64-64bit.tar.gz
tar xzvf softether-vpnserver-v4.07-9448-rtm-2014.06.06-linux-x64-64bit.tar.gz
apt-get install -y make gcc openssl build-essential
apt-get update -y && apt-get upgrade -y
apt-get dist-upgrade -y
cd $DIR/vpnserver
echo "Agree to the License Aggreement"
make
cd $DIR
mv $DIR/vpnserver /usr/local
chmod 600 /usr/local/vpnserver/*
chmod 700 /usr/local/vpnserver/vpnserver
chmod 700 /usr/local/vpnserver/vpncmd
wget https://gist.githubusercontent.com/AyushSachdev/edc23605438f1cccdd50/raw/vpnserver
mv $DIR/vpnserver /etc/init.d/vpnserver
mkdir -p /var/lock/subsys
chmod 755 /etc/init.d/vpnserver && /etc/init.d/vpnserver start
update-rc.d vpnserver defaults
cd /usr/local/vpnserver
echo "Check the VPN installation by pressing 3 and type check then quit"
./vpncmd
echo "Now setup the real VPN server"
./vpncmd
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
echo "Copy the link shown and do it"
~/.dropbox-dist/dropboxd
wget -O /bin/dropbox.py "https://www.dropbox.com/download?dl=packages/dropbox.py"
chmod +x /bin/dropbox.py
dropbox.py autostart y
dropbox.py start
dropbox.py status
dropbox.py lansync y
dropbox.py status
mkdir -p ~/Dropbox/torrents
rm -r -f /usr/share/nginx/www/torrents
ln -s ~/Dropbox/torrents /usr/share/nginx/www
#!/bin/sh
# chkconfig: 2345 99 01
# description: SoftEther VPN Server
DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment