Skip to content

Instantly share code, notes, and snippets.

@hellodaniel
Forked from zhiguangwang/README.md
Last active September 15, 2024 14:44
Show Gist options
  • Save hellodaniel/8068acefd663e29fd9dbdec47b34ad0f to your computer and use it in GitHub Desktop.
Save hellodaniel/8068acefd663e29fd9dbdec47b34ad0f to your computer and use it in GitHub Desktop.
Installing and running shadowsocks on Ubuntu Server

Installing and running shadowsocks on Ubuntu Server

  1. Install the the shadowsocks-libev package from apt repository.

     sudo apt update
     sudo apt install shadowsocks-libev
    
  2. Save config.json as /etc/shadowsocks-libev/config.json.

  3. Replace server_port and password in config.json with your own choices.

  4. Restart the shadowsocks-libev service.

     sudo systemctl restart shadowsocks-libev
     sudo systemctl status shadowsocks-libev
     sudo systemctl enable shadowsocks-libev
    

Installing and running Dante

Save install-dante.sh locally and execute the installer

    curl https://gist.githubusercontent.com/hellodaniel/8068acefd663e29fd9dbdec47b34ad0f/raw/04e9c35b735680a6370db5679ef9dbd27456befe/install-dante.sh > install-dante.sh
    chmod +x install-dante.sh
    ./install-dante.sh
{
"server":"0.0.0.0",
"mode":"tcp_and_udp",
"server_port":8080,
"password":"",
"timeout":86400,
"method":"chacha20-ietf-poly1305",
"nameserver": "1.1.1.1"
}
#!/bin/bash
echo -e "Please enter the username for the socks5 proxy:"
read username
echo -e "Please enter the password for the socks5 proxy:"
read -s password
# Update repositories
sudo apt update -y
# Install dante-server
sudo apt install dante-server -y
# Create the configuration file
sudo bash -c 'cat <<EOF > /etc/danted.conf
logoutput: /var/log/danted.log
internal: 0.0.0.0 port = 1080
external: eth0
method: username
user.privileged: root
user.notprivileged: 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
log: error
}
EOF'
# Add user with password
sudo useradd --shell /usr/sbin/nologin $username
echo "$username:$password" | sudo chpasswd
# Check if UFW is active and open port 1080 if needed
if sudo ufw status | grep -q "Status: active"; then
sudo ufw allow 1080/tcp
fi
# Check if iptables is active and open port 1080 if needed
if sudo iptables -L | grep -q "ACCEPT tcp -- anywhere anywhere tcp dpt:1080"; then
echo "Port 1080 is already open in iptables."
else
sudo iptables -A INPUT -p tcp --dport 1080 -j ACCEPT
fi
# Restart dante-server
sudo systemctl restart danted
# Enable dante-server to start at boot
sudo systemctl enable danted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment