proxy-manager/README.md
2023-04-25 22:23:31 +03:00

64 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PMGR
pmgr is wrapper utility for systemd to manage user services for prox
ies. See example for SSH SOCKS-proxy below.
# Installation
Just place pmgr into your PATH.
```
install -m755 pmgr ~/.local/bin/pmgr
```
# Usage example
For SSH SOCKS-proxy create template user unit `~/.config/systemd/user/ssh-proxy@.service` with contents:
```ini
[Unit]
Description=SSH tunnel to %I
After=network.target
[Service]
Environment="LOCAL_ADDR=localhost"
EnvironmentFile=%h/.config/pmgr/ssh-proxy@%i
ExecStart=/usr/bin/ssh -NT \
-o ServerAliveInterval=60 \
-o ExitOnForwardFailure=yes \
-D ${LOCAL_ADDR}:${LOCAL_PORT} ${TARGET}
RestartSec=5
Restart=always
[Install]
WantedBy=default.target
```
Create environment file `~/.config/pmgr/environment/ssh-proxy@myserver` with contents:
```
TARGET=user@myserver
LOCAL_ADDR=127.0.0.1
LOCAL_PORT=1080
```
`myserver` may be a domain name, SSH Hostname (set in ~/.ssh/config) or IP address of remote server.
Now you can enable your proxy with systemctl:
```
systemctl --user start ssh-proxy@myserver
```
With pmgr:
```
pmgr -e ssh-proxy@myserver
```
Proxy usage:
```
curl --proxy socks5h://localhost:1080 eth0.me
```