Pages

Monday, 23 May 2022

osx-proxy

 Turn any SSH server into a SOCKS proxy and auto-enable it in OS X.

This should work with any remote SSH server!

Move proxy to somewhere in your PATH. Make proxy executable via chmod +x proxy.

Choose between enabling proxy authorization as Environmental Variables or through directly placing credentials in proxy file.

If you choose to place the variables as Env varibles, make sure that file is sourced by your .bashrc or .zshrc.

Edit settings in proxy:

Set PROXY_USER and PROXY_HOST somewhere in sourced path ie enter following info into .bashrc or .zshrc or a more private auth file

export PROXY_USER='user'
export PROXY_HOST='example.com'

If choosing not to set credentials as Environmental Variables, replace the values below for $PROXY_USER and $PROXY_HOST with genuine credentials.

remoteuser="SSH_USER_HERE"
remoteproxy="IP_OR_HOSTNAME_HERE"
remoteport="22"

Run like this:

proxy [on|off|killall|shutdown|no_argument]

on = turn proxy on and setup ssh tunnel
off = turn proxy off
killall = kill all ssh tunnels
shutdown = off and killall
no_arg = toggle current state (if on, set as off, if off set as on) 
from https://github.com/melvinsh/osx-proxy
https://github.com/melvinsh/osx-proxy/blob/master/proxy
( 其实就是osx上的一个ssh tunnel程序)
----------------------
Bash script for starting and stopping a SOCKS proxy over SSH in Linux.

Soxy - Quick and easy SOCKS proxy management

Created by, Chris Kankiewicz & Charles Bock

Configuration

Download Soxy and extract the soxy file to your machine.

Copy the provided config.sample file to ~/.soxy/config and edit it for your configuration:

REMOTE_USER='YOUR_USERNAME'
REMOTE_HOST='TARGET_HOSTNAME'
REMOTE_PORT='22'

LOCAL_PORT='1080'

AUTO_RECONNECT=false

Make the soxy file executable by running:

chmod +x /path/to/soxy

Installation

Add a bash alias by adding the following to ~/.bash_aliases:

alias soxy='/path/to/soxy'

If you haven't already, you will also need to generate an RSA key pair with the following command:

ssh-keygen -t rsa -C "<your_hostname>"

Now copy your public key to the remote host with the following command:

ssh-copy-id user@example.com

You can now start the SOCKS proxy connection with the following command:

soxy start

Client Setup

Ubuntu

Navigate to [Gear Icon] -> System Settings -> Network. Select Network proxy from the left hand menu. Under the Method drop-down box, select Manual. For Socks Host enter localhost, and enter the port you used (default is 1080).

Firefox

From the Firefox menu navigate to Preferences -> Advanced -> Network (tab) then under the Connection heading click on the Settings button. In the menu that pops up select Manual proxy configuration. Now set the SOCKS Host to localhost and the corresponding Port to the port you specified (default is 1080).

Additionally, enable DNS request proxying by checking "Remote DNS"

Chrome

You can use this Plugin: Proxy SwitchyOmega

It's also possible to define black/white lists based on URL patterns and control exactly which route should be used (multiple proxies possible + direct).

Run on Start Up (Ubuntu)

You can configure Soxy to start at boot by adding it to Startup Applications in Ubuntu. Navigate to [Gear Icon] -> Startup Applications and click the Add button. For name enter "Soxy", then for Command put /your/path/to/soxy start and hit the Add button.

Now, whenever you first log into your system, Soxy will automatically start a SOCKS connection for you.

Periodically Check Connection and Automatically Re-connect

User cron jobs can be defined with crontab -e on most linux distributions. A possible setup could look like this:

## run every 10 minutes
*/10 * * * * /path/to/soxy status

If you want the script to attempt a re-connect as soon as the connection drops, you can set AUTO_RECONNECT=true in your ~/.soxy/config.

Usage

Start the SOCKS connection

soxy start

Stop the SOCKS connection

soxy stop

Restart the SOCKS connection (stops then starts)

soxy restart

Get the status of the SOCKS connection

soxy status 
from https://github.com/PHLAK/Soxy 
  

 

No comments:

Post a Comment