This module implements the ssh (Secure SHell) protocol for encrypted connections.

This depends on a generic session module that implements the actual login procedure of the game, tracks sessions etc.

Using standard ssh client,

class evennia.server.portal.ssh.SSHServerFactory[source]

Bases: twisted.internet.protocol.ServerFactory

This is only to name this better in logs

noisy = False

Describe this factory for log messages.

class evennia.server.portal.ssh.SshProtocol(starttuple)[source]

Bases: twisted.conch.manhole.Manhole, evennia.server.session.Session

Each account connecting over ssh gets this protocol assigned to them. All communication between game and account goes through here.

noisy = False

For setting up the account. If account is not None then we’ll login automatically.


starttuple (tuple) – A (account, factory) tuple.

terminalSize(width, height)[source]

Initialize the terminal and connect to the new session.

  • width (int) – Width of terminal.

  • height (int) – Height of terminal.


This is called when the connection is first established.


Handle ^C as an interrupt keystroke by resetting the current input variables to their initial state.


Handles EOF generally used to exit.


Handle a ‘form feed’ byte - generally used to request a screen refresh/redraw.


Quit, end, and lose the connection.


This is executed when the connection is lost for whatever reason. It can also be called directly, from the disconnect method.


reason (str) – Motivation for loosing connection.


Get client address.


address_and_port (tuple)

The client’s address and port in

a tuple. For example (‘’, 41917).


Communication User -> Evennia. Any line return indicates a command for the purpose of the MUD. So we take the user input and pass it on to the game engine.


string (str) – Input text.


Communication Evennia -> User. Any string sent should already have been properly formatted and processed before reaching this point.


string (str) – Output text.


Called when this session gets authenticated by the server.

disconnect(reason='Connection closed. Goodbye for now.')[source]

Disconnect from server.


reason (str) – Motivation for disconnect.


Data Evennia -> User

Keyword Arguments

kwargs (any) – Options to the protocol.

send_text(*args, **kwargs)[source]

Send text data. This is an in-band telnet operation.


text (str) – The first argument is always the text string to send. No other arguments are considered.

Keyword Arguments

options (dict) –

Send-option flags (booleans)

  • mxp: enforce mxp link support.

  • ansi: enforce no ansi colors.

  • xterm256: enforce xterm256 colors, regardless of ttype setting.

  • nocolor: strip all colors.

  • raw: pass string through without any ansi processing (i.e. include evennia ansi markers but do not convert them into ansi tokens)

  • echo: turn on/off line echo on the client. turn off line echo for client, for example for password. note that it must be actively turned back on again!

send_prompt(*args, **kwargs)[source]
send_default(*args, **kwargs)[source]
class evennia.server.portal.ssh.ExtraInfoAuthServer[source]

Bases: twisted.conch.ssh.userauth.SSHUserAuthServer

noisy = False

Password authentication.

Used mostly for setting up the transport so we can query username and password later.


packet (Packet) – Auth packet.

class evennia.server.portal.ssh.AccountDBPasswordChecker(factory)[source]

Bases: object

Checks the django db for the correct credentials for username/password otherwise it returns the account or None which is useful for the Realm.

noisy = False
credentialInterfaces = (<InterfaceClass twisted.cred.credentials.IUsernamePassword>,)

Initialize the factory.


factory (SSHFactory) – Checker factory.


Generic credentials.

class evennia.server.portal.ssh.PassAvatarIdTerminalRealm(transportFactory=None)[source]

Bases: twisted.conch.manhole_ssh.TerminalRealm

Returns an avatar that passes the avatarId through to the protocol. This is probably not the best way to do it.

noisy = False
class evennia.server.portal.ssh.TerminalSessionTransport_getPeer(proto, chainedProtocol, avatar, width, height)[source]

Bases: object

Taken from twisted’s TerminalSessionTransport which doesn’t provide getPeer to the transport. This one does.

noisy = False
__init__(proto, chainedProtocol, avatar, width, height)[source]

Initialize self. See help(type(self)) for accurate signature.

evennia.server.portal.ssh.getKeyPair(pubkeyfile, privkeyfile)[source]

This function looks for RSA keypair files in the current directory. If they do not exist, the keypair is created.


Creates the ssh server factory.