Skip to content

Latest commit

 

History

History
137 lines (94 loc) · 5.23 KB

README.md

File metadata and controls

137 lines (94 loc) · 5.23 KB

Latest Version License: AGPL v3 Build Status Coverage Status

chatd

An implementation of an SSH server for real-time communication that serves a chat room instead of a shell and provides encrypted messaging over SSH.

Acknowledgements

This project was greatly influenced by shazow/ssh-chat.

Core Features

  • Public and private one-on-one conversations
  • Color themes
  • Built-in chat commands
  • Emacs-style key bindings
  • Command history
  • Configurable motd (message of the day)
  • Command autocomplete
  • Load user config overrides from ENV
  • Automatically detect and handle idle users

Security and Control

  • Option to allow connections from authorized users only
  • Messaging rate-limit to prevent spam
  • Special commands for operators (/kick, /ban, /mute, etc.)

Downloading a release

Pre-built binaries of chatd for various platforms, including Windows (x86_64/ARM64), Linux (32-bit/x86_64/ARM64), and macOS (x86_64/ARM64), are available via GitHub Releases. These binaries are automatically generated with every tagged commit.

If you’re a Rust developer with Cargo installed, you can skip the download and install the daemon directly from crates.io: cargo install chatd

Compiling / Developing

To build the daemon from source, follow these steps:

$ git clone [email protected]:unrenamed/chatd.git
$ cd chatd
$ make release
$ ./target/release/chatd --version
chatd 0.2.0

For ongoing development, you can use Makefile for common tasks, or directly invoke cargo <command> if the required make rule is missing.

Additionally, if you prefer containerized development or deployment, we've provided a Dockerfile and compose.yaml to easily run chatd within a Docker container.

Quick start

chatd is an implementation of an SSH server for real-time communication that
serves a chat room instead of a shell and provides encrypted messaging over
SSH.

Usage: chatd [OPTIONS]

Options:
      --port <PORT>       Port to listen on [default: 22]
  -i, --identity <KEY>    Private key to identify server with. Defaults to a temporary ed25519 key
      --oplist <FILE>     Optional file of public keys who are operators
      --whitelist <FILE>  Optional file of public keys who are allowed to connect
      --motd <FILE>       Optional file with a message of the day or welcome message
      --log <FILE>        Write chat log to this file
  -d, --debug...          Turn debugging information on
  -h, --help              Print help
  -V, --version           Print version

Now, run:

$ chatd

This will run the daemon listening on the default port and create a temporary ed25519 key to identify server with. For production use case, you should bind a generated key like this:

$ chatd -i ~/.ssh/id_dsa

Environment Variables

Due to the lack of persistent storage for user configurations in chatd (which is intentional), users need to reapply their settings each time they connect. This can be quite inconvenient, don't you think?

Using environment variables can solve this problem.

CHATD_THEME

This variable lets you set the theme for your session. Instead of manually configuring it by running /theme hacker, you can do it like this:

$ ssh -o SetEnv "CHATD_THEME=hacker" username@<your_server_hostname>

CHATD_TIMESTAMP

This variable enables the logging of a datetime or time prefix next to each received message. Instead of running /timestamp datetime manually, you can set it like this before connecting:

$ ssh -o SetEnv "CHATD_TIMESTAMP=datetime" username@<your_server_hostname>

If you find setting extra options to ssh command tiresome, you can use a configuration file supported by your ssh client. For the OpenSSH client, there is .ssh/config file. If you don't have one, feel free to create and provide r-w access chmod 600 .ssh/config.

Now add the following lines to the config file:

Host <your_server_hostname>
    SendEnv CHATD_*

Now, add the environment variables to your shell profile. Then, you can simply run:

$ ssh username@<your_server_hostname>

Autocomplete

chatd's autocomplete is designed to be intuitive and convenient for terminal users, recognizing whether you're completing a command, its subcommand, or their arguments.

For example:

[user] /opl[user] /oplist
[user] /oplist l[user] /oplist load
[user] /oplist load m[user] /oplist load merge
[user] /oplist add al[user] /oplist add alice

So, don't hesitate to press Tab whenever you want to save some typing 😉