a zc.buildout recipe to make on-demand ssh tunnel
Project description
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.0 (2016-11-10)
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for mete0r.recipe.sshtunnel-0.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3809f6187309d9516ba444dfe13a8ddd033cd1c9acd764b75fac8cb144a3761b |
|
MD5 | c91392111458e41be7cdc8961b92b6b7 |
|
BLAKE2b-256 | c09238ac90956507a9c21c1c20bb14fc4693b84ccb912a236fbd06a4a331d82e |