Packetizer

Packet handling

exception paramiko.packet.NeedRekeyException

Exception indicating a rekey is needed.

__weakref__

list of weak references to the object (if defined)

class paramiko.packet.Packetizer(socket)

Implementation of the base SSH packet protocol.

__weakref__

list of weak references to the object (if defined)

complete_handshake()

Tells Packetizer that the handshake has completed.

handshake_timed_out()

Checks if the handshake has timed out.

If start_handshake wasn’t called before the call to this function, the return value will always be False. If the handshake completed before a timeout was reached, the return value will be False

Returns:handshake time out status, as a bool
need_rekey()

Returns True if a new set of keys needs to be negotiated. This will be triggered during a packet read or write, so it should be checked after every read or write, or at least after every few.

read_all(n, check_rekey=False)

Read as close to N bytes as possible, blocking as long as necessary.

Parameters:n (int) – number of bytes to read
Returns:the data read, as a str
Raises:EOFError – if the socket was closed before all the bytes could be read
read_message()

Only one thread should ever be in this function (no other locking is done).

Raises:SSHException – if the packet is mangled
Raises:NeedRekeyException – if the transport should rekey
readline(timeout)

Read a line from the socket. We assume no data is pending after the line, so it’s okay to attempt large reads.

send_message(data)

Write a block of data using the current cipher, as an SSH block.

set_inbound_cipher(block_engine, block_size, mac_engine, mac_size, mac_key, etm=False)

Switch inbound data cipher. :param etm: Set encrypt-then-mac from OpenSSH

set_keepalive(interval, callback)

Turn on/off the callback keepalive. If interval seconds pass with no data read from or written to the socket, the callback will be executed and the timer will be reset.

set_log(log)

Set the Python log object to use for logging.

set_outbound_cipher(block_engine, block_size, mac_engine, mac_size, mac_key, sdctr=False, etm=False)

Switch outbound data cipher. :param etm: Set encrypt-then-mac from OpenSSH

start_handshake(timeout)

Tells Packetizer that the handshake process started. Starts a book keeping timer that can signal a timeout in the handshake process.

Parameters:timeout (float) – amount of seconds to wait before timing out