Paramiko

raw JSON →
4.0.0 verified Tue May 12 auth: no python install: verified quickstart: verified

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.

pip install paramiko
error ModuleNotFoundError: No module named 'paramiko'
cause 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.
error paramiko.ssh_exception.AuthenticationException: Authentication failed.
cause 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.
error paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect to port 22 on 'IP Address'
cause 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.
error paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
cause 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)).
breaking In 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.
gotcha The 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().
gotcha The `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.
gotcha SSHClient.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.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.79s 40.9M
3.10 slim (glibc) - - 0.43s 41M
3.11 alpine (musl) - - 0.91s 43.6M
3.11 slim (glibc) - - 0.71s 44M
3.12 alpine (musl) - - 1.09s 35.3M
3.12 slim (glibc) - - 1.09s 36M
3.13 alpine (musl) - - 1.04s 34.9M
3.13 slim (glibc) - - 1.00s 35M
3.9 alpine (musl) - - 0.59s 41.1M
3.9 slim (glibc) - - 0.69s 41M

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()