google-labs-jules[bot] 45d1bae2fd Mitigate DoS by limiting concurrent handshakes
This commit introduces mechanism to limit the number of concurrent SSH
handshakes to prevent resource exhaustion (goroutines/memory) during a
SYN flood or connection flood attack.

1.  **Global Limit:** A semaphore limits total concurrent handshakes to 20.
    This applies backpressure to the `Accept` loop.
2.  **Per-IP Limit:** Using `github.com/sethvargo/go-limiter`, we now
    limit the rate of connection attempts per IP to 3 per second.
3.  **Timeout:** The initial handshake timeout is reduced from 20s to 10s.

The global semaphore is acquired before the handshake and released
immediately after the handshake completes (or fails), ensuring that
long-lived sessions do not consume a handshake slot.
2025-12-01 20:00:37 +00:00
2024-09-06 14:10:40 -04:00
2021-07-03 13:37:09 -04:00
2017-10-12 13:40:35 -04:00
2022-01-06 09:09:51 -05:00
2022-01-06 09:09:51 -05:00
2016-09-15 13:52:55 -04:00
2020-08-03 12:32:03 -04:00
2019-02-24 09:40:47 -06:00
2017-10-12 13:40:35 -04:00
2022-01-06 09:09:51 -05:00
2021-04-13 11:27:44 -04:00
2014-12-12 17:52:05 -08:00
2019-02-24 09:40:47 -06:00
2023-02-02 15:23:02 +08:00
2019-03-18 15:36:21 -04:00

Build Status GoDoc Downloads Bountysource

ssh-chat

Custom SSH server written in Go. Instead of a shell, you get a chat prompt.

Demo

Join the party:

$ ssh ssh.chat

Please abide by our project's Code of Conduct while participating in chat.

The host's public key is ssh.chat ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKPrQofxXqoz2y9A7NFkkENt6iW8/mvpfes3RY/41Oyt and the fingerprint is SHA256:yoqMXkCysMTBsvhu2yRoMUl+EmZKlvkN+ZKmL3115xU (as of 2021-10-13).

If you see something different, you might be MITM'd.

(Apologies if the server is down, try again shortly.)

Downloading a release

Recent releases include builds for MacOS (darwin/amd64) and Linux (386, amd64, and ARM6 for your RaspberryPi).

Grab the latest binary release here.

Play around with it. Additional deploy examples are here.

Compiling / Developing

Most people just want the latest binary release. If you're sure you want to compile it from source, read on:

You can compile ssh-chat by using make build. The resulting binary is portable and can be run on any system with a similar OS and CPU arch. Go 1.8 or higher is required to compile.

If you're developing on this repo, there is a handy Makefile that should set things up with make run.

Additionally, make debug runs the server with an http pprof server. This allows you to open http://localhost:6060/debug/pprof/ and view profiling data. See net/http/pprof for more information about pprof.

Quick Start

Usage:
  ssh-chat [OPTIONS]

Application Options:
  -v, --verbose    Show verbose logging.
      --version    Print version and exit.
  -i, --identity=  Private key to identify server with. (default: ~/.ssh/id_rsa)
      --bind=      Host and port to listen on. (default: 0.0.0.0:2022)
      --admin=     File of public keys who are admins.
      --allowlist= Optional file of public keys who are allowed to connect.
      --motd=      Optional Message of the Day file.
      --log=       Write chat log to this file.
      --pprof=     Enable pprof http server for profiling.

Help Options:
  -h, --help       Show this help message

After doing go get github.com/shazow/ssh-chat/... on this repo, you should be able to run a command like:

$ ssh-chat --verbose --bind ":22" --identity ~/.ssh/id_dsa

To bind on port 22, you'll need to make sure it's free (move any other ssh daemons to another port) and run ssh-chat as root (or with sudo).

Frequently Asked Questions

The FAQs can be found on the project's Wiki page. Feel free to submit more questions to be answered and added to the page.

License

MIT

Languages
Go 98.1%
Makefile 1%
Shell 0.7%
Dockerfile 0.2%