Skip to content

A wrapper for terminal applications that exposes them to telnet clients

License

Notifications You must be signed in to change notification settings

justpresident/telnet_wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Crates.io License: MIT

telnet_wrapper

A telnet server that wraps any terminal application, exposing it to telnet clients with proper protocol support.

Features

  • Wraps any terminal application and exposes it via telnet
  • Telnet protocol support using libtelnet-rs
  • Window size negotiation (NAWS) - automatically resizes the PTY when the client window changes
  • Character-by-character input (no line buffering)
  • Supports multiple concurrent clients
  • Configurable initial terminal size
  • Configurable listening port

Installation

From crates.io

cargo install telnet_wrapper

From source

git clone https://github.com/justpresident/telnet_wrapper
cd telnet_wrapper
cargo build --release

Usage

telnet_wrapper [OPTIONS] <APP_COMMAND> [APP_ARGS]...

Arguments

Argument Description
<APP_COMMAND> The application command to run within the PTY
[APP_ARGS]... Arguments to pass to the application command

Options

Option Default Description
--port <PORT> 23 Port to listen on
--rows <ROWS> 24 Initial number of rows for the PTY
--cols <COLS> 80 Initial number of columns for the PTY
-h, --help Print help
-V, --version Print version

Examples

Expose htop on port 2323

telnet_wrapper --port 2323 /usr/bin/htop

Then connect:

telnet localhost 2323

Run a shell accessible via telnet

telnet_wrapper --port 2323 /bin/bash

Run vim with a specific file

telnet_wrapper --port 2323 /usr/bin/vim /tmp/test.txt

Custom terminal size

telnet_wrapper --port 2323 --rows 40 --cols 120 /usr/bin/htop

Telnet Protocol Support

This wrapper implements the following telnet options:

Option Description
ECHO Server-side echo (enables character mode)
SGA Suppress Go Ahead (required for character mode)
NAWS Negotiate About Window Size (dynamic terminal resizing)
LINEMODE Disabled to ensure character-by-character input

Tips

  • To close a telnet connection, press Ctrl+] and then type q or press Ctrl+D
  • Ports below 1024 require root/administrator privileges. Use higher port numbers when possible
  • Don't expose terminals/shells/file editors on publicly accessible addresses! This can be easily exploited to take control over your server. Only expose services within trusted local network or securely-designed applications that do not expose a risk of damaging your system.
  • The TERM environment variable is set to xterm-256color for the wrapped application

License

MIT License - see LICENSE for details.

About

A wrapper for terminal applications that exposes them to telnet clients

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages