ZTProxy
A user-space proxy from stdin/stdout to a TCP port on a ZeroTier network using Python 3 and libzt.
Deprecated
This was written for libzt 1.3b and I have not used it since. I just tried (July 2022) and "pip install libzt" doesn't work, so that's kind of a non-starter. I have also received a report that this does not work with version 1.4.2 or 1.8.4 of libzt. If someone would like to take over maintaining it, let me know.
Overview
Like "netcat", but for talking to ZeroTier endpoints.
My initial use case is as a SSH ProxyCommand to connect from a Docker container on my CI/CD service (which not configured to allow tun/tap devices), to a deploy server reachable over ZeroTier.
Built With
Getting Started
Prerequisites
You will need a ZeroTier network VPN/Overlay. You can register for a ZeroTier network, they are free for smaller networks. This is shockingly easy to set up. You will need the network ID for the command-line below.
Use pip to install "libzt" wrappers for Python.
Installation
- Clone the repo
git clone https://github.com/linsomniac/ztproxy
- Install "libzt" Python module
pip3 install libzt
- For SSH usage, add a line similar to the following in your "~/.ssh/config" file:
Host zthost
ProxyCommand /usr/bin/python3 /path/to/ztproxy /tmp 1234567890abcdef 9994 10.3.2.1 22
Once the above is done, you can then ssh user@zthost
. If the ZeroTier
network is "Private", you will need to use the ZeroTier Central web UI
to allow the new client connection.
Usage
The command line usage is:
/usr/bin/python3 /path/to/ztproxy [IDENTITY_DIR] [NETWORK_ID] [NETWORK_PORT] [ZT_REMOTE_ADDR] [PORT]
The arguments are as follows:
IDENTITY_DIR
- This is a directory for storing identity files for the ZeroTier node endpoint. It can be "." for testing or ephemeral use cases like in a Docker container. These identity files are created by ztproxy. If you want to make multiple connections and preserve the ztproxy IP (and the allow in the ZeroTier Central UI for a Private network endpoint), make a directory for storing the identities.NETWORK_ID
- This is the ZeroTier network ID in hex, as found in the ZeroTier Central UI.NETWORK_PORT
- I don't know exactly how to find this, I've been using 9994 and it has been working.ZT_REMOTE_ADDR
- The ZeroTier IP address (found in the ZeroTier Central web UI) of the host to connect to.PORT
- The TCP port on the remote host to connect to. For example, port 22 for SSH.
License
Distributed under the Public Domain Unlicense. See LICENSE.txt
for more information.
Contact
Project Link: https://github.com/linsomniac/ztproxy