proxy-manager/README.md

64 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2023-04-25 22:19:13 +03:00
# 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
2023-04-25 22:23:31 +03:00
For SSH SOCKS-proxy create template user unit `~/.config/systemd/user/ssh-proxy@.service` with contents:
2023-04-25 22:19:13 +03:00
```ini
[Unit]
Description=SSH tunnel to %I
After=network.target
[Service]
Environment="LOCAL_ADDR=localhost"
2023-04-25 22:23:31 +03:00
EnvironmentFile=%h/.config/pmgr/ssh-proxy@%i
2023-04-25 22:19:13 +03:00
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
```
2023-04-25 22:23:31 +03:00
Create environment file `~/.config/pmgr/environment/ssh-proxy@myserver` with contents:
2023-04-25 22:19:13 +03:00
```
TARGET=user@myserver
LOCAL_ADDR=127.0.0.1
LOCAL_PORT=1080
```
2023-04-25 22:23:31 +03:00
`myserver` may be a domain name, SSH Hostname (set in ~/.ssh/config) or IP address of remote server.
2023-04-25 22:19:13 +03:00
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
```