Compare commits
3 Commits
9b4411409d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 10ba3fb664 | |||
| 6743714326 | |||
| d9021c1000 |
2
Makefile
2
Makefile
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
install -Dm 644 common_sshconfig -t "$(PREFIX)/lib/diyvpn"
|
install -Dm 644 common_sshconfig -t "$(PREFIX)/lib/diyvpn"
|
||||||
install -Dm 755 diyvpn.sh -t "$(PREFIX)/lib/diyvpn"
|
install -Dm 755 diyvpn.sh -t "$(PREFIX)/lib/diyvpn"
|
||||||
@@ -10,6 +11,7 @@ install:
|
|||||||
install -dm 755 "$(PREFIX)/lib/systemd/user-generators"
|
install -dm 755 "$(PREFIX)/lib/systemd/user-generators"
|
||||||
ln -snf ../../diyvpn/diyvpn.sh "$(PREFIX)/lib/systemd/user-generators/diyvpn"
|
ln -snf ../../diyvpn/diyvpn.sh "$(PREFIX)/lib/systemd/user-generators/diyvpn"
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -rf "$(PREFIX)/lib/diyvpn" \
|
rm -rf "$(PREFIX)/lib/diyvpn" \
|
||||||
"$(PREFIX)/bin/diyvpnctl" \
|
"$(PREFIX)/bin/diyvpnctl" \
|
||||||
|
|||||||
80
README.md
80
README.md
@@ -1,15 +1,93 @@
|
|||||||
## Simple DIY VPN
|
# Simple DIY VPN
|
||||||
|
|
||||||
|
Tool to setup SOCKS proxy using ssh dynamic forward to your own server.
|
||||||
|
Technically this is it not a VPN but practically achives the same thing for the
|
||||||
|
most common use-case - browse websites without revealing your ip address
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
* Starts automatically on demand and shuts down automatically when not used
|
||||||
|
(Using systemd socket activation)
|
||||||
|
* Works on any VPS or home server with just ssh suppport.
|
||||||
|
Distro/architecture/size does not matter. Only working ssh support required.
|
||||||
|
No other software setup required on the server
|
||||||
|
* Easy to setup multiple different VPNs to different servers. No need to change
|
||||||
|
whole system network settings.
|
||||||
|
* Simple interactive cli utility to setup. No need to create/edit config files
|
||||||
|
* Simple bash script with no dependencies - (ssh and systemd are usually
|
||||||
|
preinstalled)
|
||||||
|
* Once setup with browser extension, easy to use for non-technical users - Just
|
||||||
|
right-click and choose a container
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
* Linux system with Systemd and ssh client
|
||||||
|
* Server with ssh support. [ssh keys][3] setup for passwordless login
|
||||||
|
* Browser or any app with SOCKS proxy support. [Librewolf][2] with [Container
|
||||||
|
Proxy][1] extension allows to setup different VPN for each container
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
* Archlinux [AUR][0]
|
* Archlinux [AUR][0]
|
||||||
* Manual install: (run as root)
|
* Manual install: (run as root)
|
||||||
|
|
||||||
```
|
```
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
❯ diyvpnctl add
|
||||||
|
Server name [e.g. vps1] [required] : homets
|
||||||
|
Listen address [e.g. 127.0.0.1:9090] [required] : 127.0.0.1:8071
|
||||||
|
Idle Timeout [e.g. 5min] [5min] :
|
||||||
|
Remote server Ip [e.g. 1.2.3.4] [required] : 100.64.0.2
|
||||||
|
Remote server ssh port [e.g. 2222] [22] :
|
||||||
|
Remote server username [e.g. dave] [required] : balki
|
||||||
|
SSH private key [e.g. ~/.ssh/id_ed25519] [required] : ~/.ssh/id_ed25519
|
||||||
|
Diyvpn config for homets added. Edit below configs for further changes
|
||||||
|
==> /home/balki/.config/diyvpn/servers/homets/config.rc <==
|
||||||
|
LISTEN_ADDRESS=127.0.0.1:8071
|
||||||
|
IDLE_TIMEOUT=5min
|
||||||
|
|
||||||
|
==> /home/balki/.config/diyvpn/servers/homets/ssh_config <==
|
||||||
|
Hostname 100.64.0.2
|
||||||
|
Port 22
|
||||||
|
User balki
|
||||||
|
IdentityFile ~/.ssh/id_ed25519
|
||||||
|
|
||||||
|
# vim: set filetype=sshconfig:
|
||||||
|
|
||||||
|
❯ diyvpnctl list
|
||||||
|
config path: /home/balki/.config/diyvpn/servers
|
||||||
|
|
||||||
|
Server ListenAddress
|
||||||
|
can1 127.0.0.1:8072
|
||||||
|
homets 127.0.0.1:8071
|
||||||
|
us1 127.0.0.1:8070
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Internals
|
||||||
|
|
||||||
|
This sets up a systemd [user-generator][4]. The generator creates three units
|
||||||
|
1. A [systemd-socket][5] that listens on the configured listen address.
|
||||||
|
2. A socket activator unit that is triggered when someone connects to the
|
||||||
|
socket. This uses [systemd-socket-proxyd][6] to forward the request to the
|
||||||
|
ssh service and also setup idle timeout.
|
||||||
|
3. The ssh service unit creates the ssh connection and setups dynamic forward.
|
||||||
|
|
||||||
|
## Future Ideas
|
||||||
|
|
||||||
|
* Automatically fire up a VPS instance in a cloud provider on demand. Since
|
||||||
|
most VPS are charged pre hour, for those using rarely, don't have to pay for
|
||||||
|
entire month. A new VPS every time improves privacy.
|
||||||
|
|
||||||
[0]: https://aur.archlinux.org/packages/diyvpn-git
|
[0]: https://aur.archlinux.org/packages/diyvpn-git
|
||||||
|
[1]: https://github.com/bekh6ex/firefox-container-proxy
|
||||||
|
[2]: https://librewolf.net/
|
||||||
|
[3]: https://wiki.archlinux.org/index.php?title=SSH_keys#Copying_the_public_key_to_the_remote_server
|
||||||
|
[4]: https://man.archlinux.org/man/systemd.generator.7
|
||||||
|
[5]: https://man.archlinux.org/man/systemd.socket.5.en
|
||||||
|
[6]: https://man.archlinux.org/man/core/systemd/systemd-socket-proxyd.8.en
|
||||||
|
|||||||
15
diyvpnctl.sh
15
diyvpnctl.sh
@@ -47,15 +47,14 @@ add() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
list() {
|
list() {
|
||||||
echo "config path: $diyvpn_cfg"
|
printf "config path: %s\n\n" "$diyvpn_cfg"
|
||||||
paste <(
|
|
||||||
echo "servers"
|
|
||||||
cd "$diyvpn_cfg"
|
cd "$diyvpn_cfg"
|
||||||
basename ./*
|
|
||||||
) <(
|
printf "%-20s %s\n" "Server" "ListenAddress"
|
||||||
echo "ListenAddress"
|
for s in *; do
|
||||||
sed -n '/LISTEN/s/.*=\(.*\)/\1/p' "$diyvpn_cfg"/*/config.rc
|
printf "%-20s %s\n" "$s" "$(sed -n '/LISTEN/s/.*=\(.*\)/\1/p' "$s"/config.rc)"
|
||||||
) | column -t
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
action="${1:-none}"
|
action="${1:-none}"
|
||||||
|
|||||||
Reference in New Issue
Block a user