Skip to content

back2nix/ssh2socks5

Repository files navigation

SSH2SOCKS5 Proxy

A lightweight SOCKS5 proxy that tunnels traffic through SSH connections. Available as both a standalone Go application and an Android app.

Features

  • SOCKS5 proxy server that works over SSH tunnels
  • SSH authentication using password or private key
  • Android app with persistent connection management
  • Automatic reconnection on connection loss

Requirements

  • Nix package manager
  • SSH key access to your server
  • NekoBox app (for system-wide VPN on Android)

SSH Setup

  1. Generate SSH key (if you don't have one):
ssh-keygen -t rsa -b 4096 -f ~/.ssh/google-france-key
  1. Copy public key to your server:
ssh-copy-id -i ~/.ssh/google-france-key.pub username@your_server

Quick Start

  1. Install Nix and direnv:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  1. Set up the environment:
cd ssh2socks5
direnv allow

Or use:

nix develop
  1. Build:

For Android app:

make build-android

For standalone proxy:

make build-go
  1. Run the proxy:
make run
  • or
nix run github:back2nix/ssh2socks5#ssh2socks5 -- -lport=1081 -host=35.193.63.104 -user=bg -key=/home/bg/Documents/code/backup/.ssh/google-france-key
  • or
nix run .#ssh2socks5 -- -lport=1081 -host=35.193.63.104 -user=bg -key=/home/bg/Documents/code/backup/.ssh/google-france-key

Решение - увеличить лимиты в SSH:

sudo vim /etc/ssh/sshd_config

Найдите и измените/добавьте:

ClientAliveInterval 60
ClientAliveCountMax 2
TCPKeepAlive yes

# Для большего количества подключений
MaxStartups 100:30:200
MaxSessions 500

# Увеличиваем время на аутентификацию, чтобы меньше банило
LoginGraceTime 300
MaxAuthTries 300

# Отключаем DNS lookup для ускорения подключений
UseDNS no

Перезапустите SSH:

sudo systemctl restart ssh
Host hetzener_usa_d1
    HostName 5.161.216.208
    User root
    IdentityFile /home/bg/.ssh/id_rsa
    ControlMaster auto
    ControlPath ~/.ssh/control-%r@%h:%p
    ControlPersist 600

Usage

Desktop

Configure your applications to use the SOCKS5 proxy at 127.0.0.1:1081 (default port).

Android

  1. Install the SSH2SOCKS5 APK
  2. Enter your SSH server details and private key
  3. Start the proxy

Note: The app itself doesn't create a system-wide VPN. To route all device traffic through the proxy:

  1. Install NekoBox from F-Droid or Google Play
  2. Create a new SOCKS5 connection in NekoBox
  3. Configure it to connect to 127.0.0.1:1081
  4. Enable the VPN in NekoBox to route all device traffic through the proxy

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published