# evennia.server.portal.ssh

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`

  Bases: `twisted.internet.protocol.ServerFactory`

  This is only to name this better in logs

  `noisy` = False
  `logPrefix`()

    Describe this factory for log messages.

class `evennia.server.portal.ssh.``SshProtocol`(starttuple)

  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
  `__init__`(starttuple)

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

    Parameters

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

  `terminalSize`(width, height)

    Initialize the terminal and connect to the new session.

    Parameters

      - width (int) – Width of terminal.

      - height (int) – Height of terminal.

  `connectionMade`()

    This is called when the connection is first established.

  `handle_INT`()

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

  `handle_EOF`()

    Handles EOF generally used to exit.

  `handle_FF`()

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

  `handle_QUIT`()

    Quit, end, and lose the connection.

  `connectionLost`(reason=None)

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

    Parameters

      reason (str) – Motivation for loosing connection.

  `getClientAddress`()

    Get client address.

    Returns

      address_and_port (tuple) –

      The client’s address and port in

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

  `lineReceived`(string)

    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.

    Parameters

      string (str) – Input text.

  `sendLine`(string)

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

    Parameters

      string (str) – Output text.

  `at_login`()

    Called when this session gets authenticated by the server.

  `disconnect`(reason='Connection closed. Goodbye for now.')

    Disconnect from server.

    Parameters

      reason (str) – Motivation for disconnect.

  `data_out`(**kwargs)

    Data Evennia -> User

    Keyword Arguments

      kwargs (any) – Options to the protocol.

  `send_text`(*args, **kwargs)

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

    Parameters

      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)
  `send_default`(*args, **kwargs)

class `evennia.server.portal.ssh.``ExtraInfoAuthServer`

  Bases: `twisted.conch.ssh.userauth.SSHUserAuthServer`

  `noisy` = False
  `auth_password`(packet)

    Password authentication.

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

    Parameters

      packet (Packet) – Auth packet.

class `evennia.server.portal.ssh.``AccountDBPasswordChecker`(factory)

  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>,)
  `__init__`(factory)

    Initialize the factory.

    Parameters

      factory (SSHFactory) – Checker factory.

  `requestAvatarId`(c)

    Generic credentials.

class `evennia.server.portal.ssh.``PassAvatarIdTerminalRealm`(transportFactory=None)

  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)

  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)

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

`evennia.server.portal.ssh.``getKeyPair`(pubkeyfile, privkeyfile)

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

`evennia.server.portal.ssh.``makeFactory`(configdict)

  Creates the ssh server factory.