package module
Version: v1.10.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 20 Imported by: 0


Build Status GoDoc Downloads Bountysource


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


Join the party:

$ ssh

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

The server's RSA key fingerprint is MD5:e5:d5:d1:75:90:38:42:f6:c7:03:d7:d0:56:7d:6a:db or SHA256:HQDLlZsXL3t0lV5CHM0OXeZ5O6PcfHuzkS8cRbbTLBI. 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

  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:
      --admin=     File of public keys who are admins.
      --whitelist= 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 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.





Package sshchat is an implementation of an ssh server which serves a chat room instead of a shell.

sshd subdirectory contains the ssh-related pieces which know nothing about chat.

chat subdirectory contains the chat-related pieces which know nothing about ssh.

The Host type is the glue between the sshd and chat pieces.



This section is empty.


View Source
var ErrBanned = errors.New("banned")

ErrBanned is the error returned when a key is checked that is banned.

View Source
var ErrNotWhitelisted = errors.New("not whitelisted")

ErrNotWhitelisted Is the error returned when a key is checked that is not whitelisted, when whitelisting is enabled.


func GetPrompt

func GetPrompt(user *message.User) string

GetPrompt will render the terminal prompt string based on the user.

func SetLogger

func SetLogger(l *golog.Logger)

SetLogger sets the package logging to use l.


type Auth

type Auth struct {
	// contains filtered or unexported fields

Auth stores lookups for bans, whitelists, and ops. It implements the sshd.Auth interface.

func NewAuth

func NewAuth() *Auth

NewAuth creates a new empty Auth.

func (*Auth) AllowAnonymous

func (a *Auth) AllowAnonymous() bool

AllowAnonymous determines if anonymous users are permitted.

func (*Auth) Ban

func (a *Auth) Ban(key ssh.PublicKey, d time.Duration)

Ban will set a public key as banned.

func (*Auth) BanAddr

func (a *Auth) BanAddr(addr net.Addr, d time.Duration)

BanAddr will set an IP address as banned.

func (*Auth) BanClient

func (a *Auth) BanClient(client string, d time.Duration)

BanClient will set client version as banned. Useful for misbehaving bots.

func (*Auth) BanFingerprint

func (a *Auth) BanFingerprint(authkey string, d time.Duration)

BanFingerprint will set a public key fingerprint as banned.

func (*Auth) BanQuery

func (a *Auth) BanQuery(q string) error

BanQuery takes space-separated key="value" pairs to ban, including ip, fingerprint, client. Fields without an = will be treated as a duration, applied to the next field. For example: 5s client=foo 10min ip= Will ban client foo for 5 seconds, and ip for 10min.

func (*Auth) Banned

func (a *Auth) Banned() (ip []string, fingerprint []string, client []string)

Banned returns the list of banned keys.

func (*Auth) Check

func (a *Auth) Check(addr net.Addr, key ssh.PublicKey, clientVersion string) error

Check determines if a pubkey fingerprint is permitted.

func (*Auth) IsOp

func (a *Auth) IsOp(key ssh.PublicKey) bool

IsOp checks if a public key is an op.

func (*Auth) Op

func (a *Auth) Op(key ssh.PublicKey, d time.Duration)

Op sets a public key as a known operator.

func (*Auth) Whitelist

func (a *Auth) Whitelist(key ssh.PublicKey, d time.Duration)

Whitelist will set a public key as a whitelisted user.

type Host

type Host struct {

	// Version string to print on /version
	Version string

	// GetMOTD is used to reload the motd from an external source
	GetMOTD func() (string, error)
	// contains filtered or unexported fields

Host is the bridge between sshd and chat modules TODO: Should be easy to add support for multiple rooms, if we want.

func NewHost

func NewHost(listener *sshd.SSHListener, auth *Auth) *Host

NewHost creates a Host on top of an existing listener.

func (*Host) AutoCompleteFunction

func (h *Host) AutoCompleteFunction(u *message.User) func(line string, pos int, key rune) (newLine string, newPos int, ok bool)

AutoCompleteFunction returns a callback for terminal autocompletion

func (*Host) Connect

func (h *Host) Connect(term *sshd.Terminal)

Connect a specific Terminal to this host and its room.

func (*Host) GetUser

func (h *Host) GetUser(name string) (*message.User, bool)

GetUser returns a message.User based on a name.

func (*Host) InitCommands

func (h *Host) InitCommands(c *chat.Commands)

InitCommands adds host-specific commands to a Commands container. These will override any existing commands.

func (*Host) Serve

func (h *Host) Serve()

Serve our chat room onto the listener

func (*Host) SetMotd

func (h *Host) SetMotd(motd string)

SetMotd sets the host's message of the day. TODO: Change to SetMOTD

func (*Host) SetTheme

func (h *Host) SetTheme(theme message.Theme)

SetTheme sets the default theme for the host.

type Identity

type Identity struct {
	// contains filtered or unexported fields

Identity is a container for everything that identifies a client.

func NewIdentity

func NewIdentity(conn sshd.Connection) *Identity

NewIdentity returns a new identity object from an sshd.Connection.

func (Identity) ID

func (i Identity) ID() string

ID returns the name for the Identity

func (Identity) Name

func (i Identity) Name() string

Name returns the name for the Identity

func (*Identity) SetID

func (i *Identity) SetID(id string)

SetID Changes the Identity's name

func (*Identity) SetName

func (i *Identity) SetName(name string)

SetName Changes the Identity's name

func (*Identity) SetSymbol added in v1.10.1

func (i *Identity) SetSymbol(symbol string)

func (Identity) Whois

func (i Identity) Whois() string

Whois returns a whois description for non-admin users. TODO: Add optional room context?

func (Identity) WhoisAdmin

func (i Identity) WhoisAdmin(room *chat.Room) string

WhoisAdmin returns a whois description for admin users.


Path Synopsis
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL