67 lines
1.2 KiB
Markdown
67 lines
1.2 KiB
Markdown
|
# 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/sys‐
|
|||
|
temd/user/ssh-proxy@.service with contents:
|
|||
|
|
|||
|
```ini
|
|||
|
[Unit]
|
|||
|
Description=SSH tunnel to %I
|
|||
|
After=network.target
|
|||
|
|
|||
|
[Service]
|
|||
|
Environment="LOCAL_ADDR=localhost"
|
|||
|
EnvironmentFile=%h/.config/proxy-manager/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
|
|||
|
```
|
|||
|
|
|||
|
In there 'mysserver' 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
|
|||
|
```
|