host.telnet

Telnet client for remote host connections.

TelnetClient handles the transport-level concerns: opening a telnet connection, negotiating protocol options (echo suppression), authenticating, and optionally sending NAWS (window-size) updates on SIGWINCH so remote TUIs reflow like they do under SSH. After login the reader/writer streams are handed off to a TelnetSession for command execution.

class otto.host.telnet.TelnetClient(host, user, password, options=<factory>, prompt=None, connect_port=None)

Bases: object

host : --is-rst--:py:class:`str`
user : --is-rst--:py:class:`str`
password : --is-rst--:py:class:`str`
options : --is-rst--:py:class:`~otto.host.options.TelnetOptions`

Connection options. Default reproduces otto’s historical behavior.

prompt : --is-rst--:py:data:`~typing.Optional`\ \[:py:class:`str`] = None

Shell prompt string the device displays after each command (e.g. ‘$ ‘ or ‘# ‘). Used during login to confirm authentication succeeded.

connect_port : --is-rst--:py:data:`~typing.Optional`\ \[:py:class:`int`] = None

Override port for ConnectionManager’s tunneled case. When None, options.port is used. Keeps tunnel port-forwarding transparent to the TelnetOptions carried through the rest of the stack.

reader : --is-rst--:py:data:`~typing.Any` = None
writer : --is-rst--:py:data:`~typing.Any` = None
async connect(interactive=False)

Open the telnet connection, negotiate options, and log in.

Parameters:

interactive – When True, skip the DONT ECHO negotiation so the remote shell echoes keystrokes back — required for otto.host.interact.run_telnet_login() so the user sees what they type. Non-interactive callers (the default) get DONT ECHO so command echoes don’t mix with captured output.

Return type:

None

async login()

Send credentials through an established telnet stream.

Return type:

None

async close()

Gracefully close the telnet connection.

Return type:

None