1 from logging import Logger
2 from socket import socket
3 from threading import Condition, Event, Lock, Thread
4 from types import ModuleType
5 from typing import Any, Callable, Iterable, Protocol, Sequence, Tuple, Type
7 from paramiko.auth_handler import AuthHandler, _InteractiveCallback
8 from paramiko.channel import Channel
9 from paramiko.message import Message
10 from paramiko.packet import Packetizer
11 from paramiko.pkey import PKey
12 from paramiko.server import ServerInterface, SubsystemHandler
13 from paramiko.sftp_client import SFTPClient
14 from paramiko.ssh_gss import _SSH_GSSAuth
15 from paramiko.util import ClosingContextManager
17 _Addr = Tuple[str, int]
19 class _KexEngine(Protocol):
20 def start_kex(self) -> None: ...
21 def parse_next(self, ptype: int, m: Message) -> None: ...
23 class Transport(Thread, ClosingContextManager):
27 packetizer: Packetizer
31 local_kex_init: bytes | None
33 local_compression: str | None
34 session_id: bytes | None
35 host_key_type: str | None
39 kexgss_ctxt: _SSH_GSSAuth | None
41 kex_engine: _KexEngine | None
44 initial_kex_done: bool
48 channel_events: dict[int, Event]
49 channels_seen: dict[int, bool]
50 default_max_packet_size: int
51 default_window_size: int
52 saved_exception: Exception | None
54 clear_to_send_lock: Lock
55 clear_to_send_timeout: float
58 auth_handler: AuthHandler | None
59 global_response: Message | None
60 completion_event: Event | None
62 handshake_timeout: float
64 disabled_algorithms: dict[str, Iterable[str]] | None
66 server_object: ServerInterface | None
67 server_key_dict: dict[str, PKey]
68 server_accepts: list[Channel]
69 server_accept_cv: Condition
70 subsystem_table: dict[str, tuple[Type[SubsystemHandler], Tuple[Any, ...], dict[str, Any]]]
74 sock: str | tuple[str, int] | socket,
75 default_window_size: int = ...,
76 default_max_packet_size: int = ...,
78 gss_deleg_creds: bool = ...,
79 disabled_algorithms: dict[str, Iterable[str]] | None = ...,
82 def preferred_ciphers(self) -> Sequence[str]: ...
84 def preferred_macs(self) -> Sequence[str]: ...
86 def preferred_keys(self) -> Sequence[str]: ...
88 def preferred_kex(self) -> Sequence[str]: ...
90 def preferred_compression(self) -> Sequence[str]: ...
91 def atfork(self) -> None: ...
92 def get_security_options(self) -> SecurityOptions: ...
93 def set_gss_host(self, gss_host: str | None, trust_dns: bool = ..., gssapi_requested: bool = ...) -> None: ...
94 def start_client(self, event: Event | None = ..., timeout: float | None = ...) -> None: ...
95 def start_server(self, event: Event = ..., server: ServerInterface | None = ...) -> None: ...
96 def add_server_key(self, key: PKey) -> None: ...
97 def get_server_key(self) -> PKey | None: ...
99 def load_server_moduli(filename: str | None = ...) -> bool: ...
100 def close(self) -> None: ...
101 def get_remote_server_key(self) -> PKey: ...
102 def is_active(self) -> bool: ...
104 self, window_size: int | None = ..., max_packet_size: int | None = ..., timeout: float | None = ...
106 def open_x11_channel(self, src_addr: _Addr = ...) -> Channel: ...
107 def open_forward_agent_channel(self) -> Channel: ...
108 def open_forwarded_tcpip_channel(self, src_addr: _Addr, dest_addr: _Addr) -> Channel: ...
112 dest_addr: _Addr | None = ...,
113 src_addr: _Addr | None = ...,
114 window_size: int | None = ...,
115 max_packet_size: int | None = ...,
116 timeout: float | None = ...,
118 def request_port_forward(
119 self, address: str, port: int, handler: Callable[[Channel, _Addr, _Addr], None] | None = ...
121 def cancel_port_forward(self, address: str, port: int) -> None: ...
122 def open_sftp_client(self) -> SFTPClient | None: ...
123 def send_ignore(self, byte_count: int = ...) -> None: ...
124 def renegotiate_keys(self) -> None: ...
125 def set_keepalive(self, interval: int) -> None: ...
126 def global_request(self, kind: str, data: Iterable[Any] | None = ..., wait: bool = ...) -> Message | None: ...
127 def accept(self, timeout: float | None = ...) -> Channel | None: ...
130 hostkey: PKey | None = ...,
132 password: str | None = ...,
133 pkey: PKey | None = ...,
134 gss_host: str | None = ...,
135 gss_auth: bool = ...,
137 gss_deleg_creds: bool = ...,
138 gss_trust_dns: bool = ...,
140 def get_exception(self) -> Exception | None: ...
141 def set_subsystem_handler(self, name: str, handler: Type[SubsystemHandler], *larg: Any, **kwarg: Any) -> None: ...
142 def is_authenticated(self) -> bool: ...
143 def get_username(self) -> str | None: ...
144 def get_banner(self) -> bytes | None: ...
145 def auth_none(self, username: str) -> list[str]: ...
146 def auth_password(self, username: str, password: str, event: Event | None = ..., fallback: bool = ...) -> list[str]: ...
147 def auth_publickey(self, username: str, key: PKey, event: Event | None = ...) -> list[str]: ...
148 def auth_interactive(self, username: str, handler: _InteractiveCallback, submethods: str = ...) -> list[str]: ...
149 def auth_interactive_dumb(
150 self, username: str, handler: _InteractiveCallback | None = ..., submethods: str = ...
152 def auth_gssapi_with_mic(self, username: str, gss_host: str, gss_deleg_creds: bool) -> list[str]: ...
153 def auth_gssapi_keyex(self, username: str) -> list[str]: ...
154 def set_log_channel(self, name: str) -> None: ...
155 def get_log_channel(self) -> str: ...
156 def set_hexdump(self, hexdump: bool) -> None: ...
157 def get_hexdump(self) -> bool: ...
158 def use_compression(self, compress: bool = ...) -> None: ...
159 def getpeername(self) -> tuple[str, int]: ...
160 def stop_thread(self) -> None: ...
161 def run(self) -> None: ...
163 class SecurityOptions:
164 def __init__(self, transport: Transport) -> None: ...
166 def ciphers(self) -> Sequence[str]: ...
168 def ciphers(self, x: Sequence[str]) -> None: ...
170 def digests(self) -> Sequence[str]: ...
172 def digests(self, x: Sequence[str]) -> None: ...
174 def key_types(self) -> Sequence[str]: ...
176 def key_types(self, x: Sequence[str]) -> None: ...
178 def kex(self) -> Sequence[str]: ...
180 def kex(self, x: Sequence[str]) -> None: ...
182 def compression(self) -> Sequence[str]: ...
184 def compression(self, x: Sequence[str]) -> None: ...
187 def __init__(self) -> None: ...
188 def put(self, chanid: int, chan: Channel) -> None: ...
189 def get(self, chanid: int) -> Channel: ...
190 def delete(self, chanid: int) -> None: ...
191 def values(self) -> list[Channel]: ...
192 def __len__(self) -> int: ...