r/LinuxTeck • u/Expensive-Rice-2052 • 5d ago
Quick Linux Tip #133 - Socat Linux Command: Create Secure TLS Connections
Question: I need two scripts to talk securely over the local network.
Try: socat OPENSSL-LISTEN:4433,cert=server.pem,key=server.key,verify=0,fork SYSTEM:'/opt/handler.sh'
Info: Relays encrypted TLS streams between commands and sockets.
Examples:
$ socat TCP-LISTEN:8080,fork EXEC:'cat file.txt' # Serve a file over a reusable TCP listener
$ socat - UNIX-CONNECT:/var/run/docker.sock # Connect interactively to a UNIX domain socket
$ socat TCP4-LISTEN:8080,fork TCP4:remote:80 # Forward incoming IPv4 traffic to a remote port
Note: Install via sudo apt install socat. `socat` chains bidirectional data streams across sockets, files, pipes, and TLS—use `verify=1` with a CA bundle in production instead of skipping certificate checks.
Want to master Linux one command at a time?
Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/