Skip to content

Instantly share code, notes, and snippets.

@broadwaylamb
Last active April 18, 2018 17:16
Show Gist options
  • Save broadwaylamb/a748fdbc99128a16cb830eb74d5b2869 to your computer and use it in GitHub Desktop.
Save broadwaylamb/a748fdbc99128a16cb830eb74d5b2869 to your computer and use it in GitHub Desktop.
SOCKS5
# Assuming we've successfully setup DigitalOcean droplet and logged in as root.
apt-get update
apt-get upgrade
apt-get install build-essential libwrap0-dev libpam0g-dev libkrb5-dev libsasl2-dev
# Substitute this URL to point to the latest dante version (1.4.2 as of April 2018)
wget https://www.inet.no/dante/files/dante-1.4.2.tar.gz
tar -xvf dante-1.4.1.tar.gz
cd dante-1.4.1
apt-get install libwrap0 libwrap0-dev
apt-get install gcc make
mkdir /home/dante
./configure --prefix=/home/dante
make
make install
echo '
errorlog: /var/log/sockd.errlog
logoutput: syslog /var/log/danted.log
internal: eth0 port = 1080
external: eth0
 
socksmethod: username
user.privileged: root
user.unprivileged: nobody
 
client pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: error
}
 
socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    command: connect
    log: error
    method: username
}' > /home/dante/danted.conf
# Create a new user "tg_socks_user" for the clients to login.
# Note the `--shell /usr/sbin/nologin` flag.
# This ensures the user cannot ssh to our server.
sudo useradd --shell /usr/sbin/nologin -m tg_socks_user && sudo passwd soksuser
sudo apt-get install ufw
sudo ufw status
sudo ufw allow ssh
sudo ufw allow proto tcp from any to any port 1080
sudo ufw status numbered
sudo ufw enable
# We need to start the server after reboot. We use cron for that.
sudo apt-get install cron
# Edit the crontab
crontab -e
# Paste the following two lines into the editor
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Start the server as a daemon, save its PID to the `/var/run/sockd.pid` file.
/home/dante/sbin/sockd -f /home/dante/danted.conf -D -p /var/run/sockd.pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment