mete0r.recipe.sshtunnel
a zc.buildout recipe to make on-demand ssh tunnels i.e. ssh -L, using systemd socket activation.
Requirements
Local side |
Remote side |
systemd |
sshd |
ssh |
nc |
Usage example
In your buildout.cfg, define a zc.recipe.deployment section:
[buildout] parts = tunnel [foo] recipe = zc.recipe.deployment prefix = FOO-DIR etc-user = MY-USERNAME user = MY-USERNAME ...
Then define a tunnel socket in the deployment:
[foo-db] recipe = mete0r.recipe.sshtunnel deployment = foo socket.name = mysql.sock ssh.process.user = MY-USERNAME ssh.hostname = 192.168.0.2 remote.bind = 127.0.0.1:3306
On buildout run, two systemd unit files will be created:
$ ls -l ~/.config/systemd/user/ foo-db.socket foo-db@.service
Then you can start the listening socket:
$ systemctl --user start foo-db.socket $ systemctl --user list-sockets --all LISTEN UNIT ACTIVATES FOO-DIR/var/run/foo/mysql.sock foo-db.socket foo-db@0.service
Test it:
$ mysql --socket=FOO-DIR/var/run/foo/mysql.sock
Enable it to persist:
$ systemctl --user enable foo-db.socket
Development environment
To setup development environment:
python setup.py virtualenv make
Changes
0.0.1 (2016-11-10)
Fix service unit ‘User=’ configuration for non-root users.
0.0.0 (2016-11-10)
Initial release.
Metadata
Release files for mete0r.recipe.sshtunnel 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mete0r.recipe.sshtunnel-0.0.1.tar.gz | 75.8 kB | Details |
Release files / mete0r.recipe.sshtunnel-0.0.1.tar.gz
| Download URL | mete0r.recipe.sshtunnel-0.0.1.tar.gz |
|---|---|
| Size | 75.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00fb8686467609ee2f9742d5a8db8845654e4d4c4bb83afd597143e7bebad15f
|
|
BLAKE2b-256 checksum How to use checksums |
1b604d0b2fc045a7bd5967155bdd93b3cb72609f826ea3f40f244f1deca9c361
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |