{"id":411,"library":"paramiko","title":"Paramiko","description":"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.","status":"active","version":"4.0.0","language":"python","source_language":"en","source_url":"https://github.com/paramiko/paramiko","tags":["SSH","Python","Networking","Security"],"install":[{"cmd":"pip install paramiko","lang":"bash","label":"Install Paramiko"}],"dependencies":[{"reason":"Provides cryptographic recipes and primitives for Paramiko","package":"cryptography","optional":false}],"imports":[{"note":"Ensure correct import path to avoid ImportError.","symbol":"SSHClient","correct":"from paramiko import SSHClient"},{"note":"Ensure correct import path to avoid ImportError.","symbol":"AutoAddPolicy","correct":"from paramiko import AutoAddPolicy"}],"quickstart":{"code":"import os\nfrom paramiko import SSHClient, AutoAddPolicy\n\n# Set up SSH client\nclient = SSHClient()\nclient.set_missing_host_key_policy(AutoAddPolicy())\n\n# Connect to the server\nclient.connect(os.environ.get('SSH_HOST', 'hostname'), username=os.environ.get('SSH_USER', 'user'), password=os.environ.get('SSH_PASSWORD', 'password'))\n\n# Execute a command\nstdin, stdout, stderr = client.exec_command('ls')\nprint(stdout.read().decode())\n\n# Close the connection\nclient.close()","lang":"python","description":"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."},"warnings":[{"fix":"Review and manage host key policies to ensure secure connections.","message":"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.","severity":"breaking","affected_versions":"4.0.0"},{"fix":"Ensure all required parameters are provided when calling SSHClient.connect().","message":"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.","severity":"gotcha","affected_versions":"4.0.0"},{"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.","message":"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.","severity":"gotcha","affected_versions":"4.0.0"},{"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.","message":"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.","severity":"gotcha","affected_versions":"4.0.0"}],"env_vars":null,"last_verified":"2026-05-12T13:39:42.208Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"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.","cause":"The Paramiko library is not installed in the Python environment being used, or the incorrect Python interpreter is active.","error":"ModuleNotFoundError: No module named 'paramiko'"},{"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.","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).","error":"paramiko.ssh_exception.AuthenticationException: Authentication failed."},{"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.","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.","error":"paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect to port 22 on 'IP Address'"},{"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)`).","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.","error":"paramiko.ssh_exception.SSHException: Error reading SSH protocol banner"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.79,"mem_mb":13,"disk_size":"40.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.43,"mem_mb":13,"disk_size":"41M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.91,"mem_mb":14.4,"disk_size":"43.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.71,"mem_mb":14.4,"disk_size":"44M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.09,"mem_mb":14.5,"disk_size":"35.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.09,"mem_mb":14.5,"disk_size":"36M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.04,"mem_mb":15.3,"disk_size":"34.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1,"mem_mb":15.3,"disk_size":"35M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.59,"mem_mb":12.5,"disk_size":"41.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.69,"mem_mb":12.5,"disk_size":"41M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}