malai tcp: Share a TCP Service Using malai
Starting malai-0.2.3. You can share your local TCP server with the world. This can be your database server or ssh server for example.
Usage
Assuming a tcp server is running on your local machine on port 5432, you can use the following command to share it:
Malai Expose TCP
$ malai tcp 5432 --public
Malai: Sharing port 5432
Run malai tcp-bridge <id52> <some-port>
to connect to it from any machine.
Lang:
bash
Now anyone can connect to this exposed server from their machine using malai tcp-bridge:
Connect to TCP Server
$ malai tcp-bridge <id52> 9091
Listening on 127.0.0.1:9091
Lang:
bash

This will start a TCP server on their computer and they'll use this TCP server as if they're connecting to your real TCP server running on port 5432.

So if it's a postgres server, they can connect to it using the following command:
Connect to TCP Server
psql 'postgresql://user:passwd@localhost:9091/db_name'
Lang:
bash
And it'll connect to your postgres server listening on port 5432 on your machine!
Share SSH using malai tcp
First, ensure the OpenSSH server is running (it usually listens on port 22). You can check its status with:
$ systemctl status sshd
Lang:
bash

You don’t need to expose port 22 publicly — malai connects to it locally on this machine.

To share the SSH port using malai tcp, run:
$ malai tcp 22 --public

Malai: Sharing port 22
Run malai tcp-bridge <id52> <some-port>
to connect to it from any machine.
Lang:
bash
On another machine, run the following to connect:
$ malai tcp-bridge <id52> 9090

Listening on 127.0.0.1:9090
Lang:
bash

Replace <id52> with the ID shown by the malai tcp command.

Once the bridge is running, you can SSH into the machine like this:
$ ssh -p 9090 user@localhost
Lang:
bash
Use the appropriate user that exists on the remote machine. The SSH connection goes to localhost:9090, where tcp-bridge is listening. It then forwards the traffic to the remote machine via the Kulfi network using <id52>.
© 2025 FifthTry, Inc