Skip to content

Instantly share code, notes, and snippets.

@jasonlai
Last active March 27, 2018 20:18
Show Gist options
  • Save jasonlai/e03b635f28441b9a5069d0c73e898a75 to your computer and use it in GitHub Desktop.
Save jasonlai/e03b635f28441b9a5069d0c73e898a75 to your computer and use it in GitHub Desktop.
Poor man's telnet server in Bash
# Session 3
sudo setsid bash -l < /var/run/my-telnet > /var/run/my-telnet 2>&1 # Bash expects itself as a session leader
# Client - Session 2
nc $HOST_OF_SESSION1 1234 # After the connection is established the pty link is created on the host of the socat process
# Server - Session 1
# Use `socat(1)` to listen on a TCP port, connecting its output to the input end of a PTY slave and input to the output end of the PTY slave
sudo socat TCP-LISTEN:1234,reuseaddr PTY,link=/var/run/my-telnet,user="$(id -un)",group="$(id -gn)",waitslave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment