ssh-chat: Index | Files | Directories

package sshchat

import ""

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.


Package Files

auth.go godoc.go host.go identity.go logger.go


var ErrBanned = errors.New("banned")

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

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 Uses

func GetPrompt(user *message.User) string

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

func SetLogger Uses

func SetLogger(l *golog.Logger)

SetLogger sets the package logging to use l.

type Auth Uses

type Auth struct {
    // contains filtered or unexported fields

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

func NewAuth Uses

func NewAuth() *Auth

NewAuth creates a new empty Auth.

func (*Auth) AllowAnonymous Uses

func (a *Auth) AllowAnonymous() bool

AllowAnonymous determines if anonymous users are permitted.

func (*Auth) Ban Uses

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

Ban will set a public key as banned.

func (*Auth) BanAddr Uses

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

BanAddr will set an IP address as banned.

func (*Auth) BanClient Uses

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

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

func (*Auth) BanFingerprint Uses

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

BanFingerprint will set a public key fingerprint as banned.

func (*Auth) BanQuery Uses

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 Uses

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

Banned returns the list of banned keys.

func (*Auth) Check Uses

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

Check determines if a pubkey fingerprint is permitted.

func (*Auth) IsOp Uses

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

IsOp checks if a public key is an op.

func (*Auth) Op Uses

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

Op sets a public key as a known operator.

func (*Auth) Whitelist Uses

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

Whitelist will set a public key as a whitelisted user.

type Host Uses

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 Uses

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

NewHost creates a Host on top of an existing listener.

func (*Host) AutoCompleteFunction Uses

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 Uses

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

Connect a specific Terminal to this host and its room.

func (*Host) GetUser Uses

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

GetUser returns a message.User based on a name.

func (*Host) InitCommands Uses

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 Uses

func (h *Host) Serve()

Serve our chat room onto the listener

func (*Host) SetMotd Uses

func (h *Host) SetMotd(motd string)

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

func (*Host) SetTheme Uses

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

SetTheme sets the default theme for the host.

type Identity Uses

type Identity struct {
    // contains filtered or unexported fields

Identity is a container for everything that identifies a client.

func NewIdentity Uses

func NewIdentity(conn sshd.Connection) *Identity

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

func (Identity) ID Uses

func (i Identity) ID() string

ID returns the name for the Identity

func (Identity) Name Uses

func (i Identity) Name() string

Name returns the name for the Identity

func (*Identity) SetID Uses

func (i *Identity) SetID(id string)

SetID Changes the Identity's name

func (*Identity) SetName Uses

func (i *Identity) SetName(name string)

SetName Changes the Identity's name

func (*Identity) SetSymbol Uses

func (i *Identity) SetSymbol(symbol string)

func (Identity) Whois Uses

func (i Identity) Whois() string

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

func (Identity) WhoisAdmin Uses

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

WhoisAdmin returns a whois description for admin users.


sshd/terminalPackage terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.

Package sshchat imports 20 packages (graph) and is imported by 1 packages. Updated 2020-08-06. Refresh now. Tools for package owners.