Skip to content

Instantly share code, notes, and snippets.

@astappiev
Created March 31, 2025 07:14
Show Gist options
  • Select an option

  • Save astappiev/01c019e2be858b5bbb0ec2ac7c42f4fc to your computer and use it in GitHub Desktop.

Select an option

Save astappiev/01c019e2be858b5bbb0ec2ac7c42f4fc to your computer and use it in GitHub Desktop.
Rathole install script
#!/bin/bash
set -e
echo "Installing Rathole..."
apt install -y unzip
RATHOLE_VERSION="v0.5.0"
RATHOLE_URL="https://github.com/rapiz1/rathole/releases/download/${RATHOLE_VERSION}/rathole-x86_64-unknown-linux-gnu.zip"
echo "Downloading Rathole ${RATHOLE_VERSION}..."
wget $RATHOLE_URL
unzip rathole-x86_64-unknown-linux-gnu.zip
# Move binary to /usr/local/bin
echo "Installing Rathole binary..."
mv rathole /usr/local/bin/
chmod +x /usr/local/bin/rathole
# Create configuration directory
echo "Setting up configuration..."
mkdir -p /etc/rathole
# Create default configuration file
cat >/etc/rathole/rathole.toml <<'EOF'
# Default Rathole configuration
# Edit this file according to your needs
[client]
remote_addr = "example.com:2333"
[client.transport]
type = "noise"
[client.transport.noise]
remote_public_key = "public_key_here"
[client.services.service1]
local_addr = "127.0.0.1:8080"
token = "change_this_token"
EOF
echo "Configuration file created at /etc/rathole/rathole.toml"
echo "Please edit this file with your specific configuration"
# Create systemd service
echo "Creating systemd service..."
cat >/etc/systemd/system/rathole.service <<'EOF'
[Unit]
Description=Rathole Client Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/rathole -c /etc/rathole/rathole.toml
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd, enable and start the service
echo "Enabling and starting Rathole service..."
systemctl daemon-reload
systemctl enable rathole
systemctl start rathole
# Check service status
echo "Checking service status..."
systemctl status rathole --no-pager
echo "Rathole installation complete!"
echo "Make sure to edit /etc/rathole/rathole.toml with your specific configuration."
echo "You can manage the service using: systemctl [start|stop|restart|status] rathole"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment