Registry / http-networking / paramiko

paramiko

JSON →
library4.0.0pypypi✓ verified 52d ago

Paramiko is a native Python SSHv2 protocol library, providing both client and server functionality. The current version is 4.0.0, released on March 28, 2026. It follows a regular release cadence, with updates and patches released as needed.

http-networkingauth-security
pip install paramiko
Install & Compatibility
Where this runs
tested against v5.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.834s · 41.8MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 2.8s · import 0.750s · 42MB
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SSHClient
from paramiko import SSHClient
Ensure correct import path to avoid ImportError.
AutoAddPolicy
from paramiko import AutoAddPolicy
Ensure correct import path to avoid ImportError.

A basic example demonstrating how to use Paramiko to connect to an SSH server and execute a command. Replace 'hostname', 'user', and 'password' with your server's details, or set them as environment variables.

import os from paramiko import SSHClient, AutoAddPolicy # Set up SSH client client = SSHClient() client.set_missing_host_key_policy(AutoAddPolicy()) # Connect to the server client.connect(os.environ.get('SSH_HOST', 'hostname'), username=os.environ.get('SSH_USER', 'user'), password=os.environ.get('SSH_PASSWORD', 'password')) # Execute a command stdin, stdout, stderr = client.exec_command('ls') print(stdout.read().decode()) # Close the connection client.close()
Debug
Known issues
breakingIn version 4.0.0, the default policy for handling unknown host keys has changed to AutoAddPolicy, which automatically adds unknown host keys to the local host key database. This may introduce security risks if not properly managed.
fix
Review and manage host key policies to ensure secure connections.
affects: 4.0.0
gotchaThe SSHClient.connect() method now requires the 'hostname', 'username', and 'password' parameters to be explicitly provided or set as environment variables. Omitting these will result in a TypeError.
fix
Ensure all required parameters are provided when calling SSHClient.connect().
affects: 4.0.0
gotchaThe `SSHClient.connect()` method attempts to resolve the provided hostname. If the hostname is unresolvable (e.g., an invalid string like 'hostname' used as a placeholder, or a non-existent domain), a `socket.gaierror: [Errno -2] Name or service not known` will be raised.
fix
Ensure the `hostname` parameter passed to `SSHClient.connect()` is a valid and resolvable network address or hostname. Avoid using placeholder hostnames like 'hostname' in environments where network resolution is expected, or ensure such placeholders are replaced by actual, resolvable hosts.
affects: 4.0.0
gotchaSSHClient.connect() might fail with `socket.gaierror: [Errno -2] Name does not resolve` if the hostname provided cannot be resolved to an IP address. This is typically due to incorrect hostname, DNS misconfiguration, or network connectivity issues.
fix
Ensure the hostname provided to SSHClient.connect() is correct and resolvable within the network environment. Verify DNS settings or use a direct IP address if hostname resolution is problematic.
affects: 4.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'paramiko'
The Paramiko library is not installed in the Python environment being used, or the incorrect Python interpreter is active.
fix
Run `pip install paramiko` (or `pip3 install paramiko` for Python 3 specific installation, or `conda install paramiko` if using Anaconda) in your terminal to install the library.
paramiko.ssh_exception.AuthenticationException: Authentication failed.
The provided username, password, or private key is incorrect, or the SSH server configuration does not permit the attempted authentication method (e.g., password authentication is disabled).
fix
Verify that the username, password, or private key path and passphrase are correct. You might need to explicitly set `look_for_keys=False` and `allow_agent=False` in `client.connect()` to prevent Paramiko from trying system SSH keys or agent, and then specify your desired authentication method.
paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect to port 22 on 'IP Address'
The Paramiko client could not establish a TCP connection to the specified host and port. This often indicates that the host is unreachable, a firewall is blocking the connection, or no SSH server is listening on the target port.
fix
Check the target hostname and port for correctness. Verify network connectivity using tools like `ping` or `telnet` to the target IP and port. Ensure no local or remote firewalls are blocking port 22 (or the custom SSH port) and that the SSH daemon is running on the remote server.
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
The client successfully established a TCP connection, but the service listening on the port is not an SSH server, or the SSH server did not send its protocol banner within the expected timeout period, possibly due to network congestion or a heavily loaded server.
fix
Confirm that an SSH server is indeed running on the target port (default 22). If the server is slow, increase the `banner_timeout` parameter in the `client.connect()` call (e.g., `client.connect(hostname, username, password, banner_timeout=30)`).
Upgrade
Version history
5.0.0latest on PyPI
Audit
Dependencies
cryptographyrequiredProvides cryptographic recipes and primitives for Paramiko
Agent activity
13 hits · last 30 days
node
4
seranking-bot
4
ahrefsbot
3
bytedance
1
Resources