Skip to main content

AsyncSSH: Asynchronous SSHv2 client and server library

Project description

Documentation Status AsyncSSH PyPI Project

AsyncSSH: Asynchronous SSH for Python

AsyncSSH is a Python package which provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python 3.10+ asyncio framework.

import asyncio, asyncssh, sys

async def run_client():
    async with asyncssh.connect('localhost') as conn:
        result = await conn.run('echo "Hello!"', check=True)
        print(result.stdout, end='')

try:
    asyncio.get_event_loop().run_until_complete(run_client())
except (OSError, asyncssh.Error) as exc:
    sys.exit('SSH connection failed: ' + str(exc))

Check out the examples to get started!

Features

  • Full support for SSHv2, SFTP, and SCP client and server functions

    • Shell, command, and subsystem channels

    • Environment variables, terminal type, and window size

    • Direct and forwarded TCP/IP channels

    • OpenSSH-compatible direct and forwarded UNIX domain socket channels

    • OpenSSH-compatible TUN/TAP channels and packet forwarding

    • Local and remote TCP/IP port forwarding

    • Local and remote UNIX domain socket forwarding

    • Dynamic TCP/IP port forwarding via SOCKS

    • X11 forwarding support on both the client and the server

    • SFTP protocol version 3 with OpenSSH extensions

      • Experimental support for SFTP versions 4-6, when requested

    • SCP protocol support, including third-party remote to remote copies

  • Multiple simultaneous sessions on a single SSH connection

  • Multiple SSH connections in a single event loop

  • Byte and string based I/O with settable encoding

  • A variety of key exchange, encryption, and MAC algorithms

    • Including post-quantum kex algorithms ML-KEM and SNTRUP

  • Support for gzip compression

    • Including OpenSSH variant to delay compression until after auth

  • User and host-based public key, password, and keyboard-interactive authentication methods

  • Many types and formats of public keys and certificates

    • Including OpenSSH-compatible support for U2F and FIDO2 security keys

    • Including PKCS#11 support for accessing PIV security tokens

    • Including support for X.509 certificates as defined in RFC 6187

  • Support for accessing keys managed by ssh-agent on UNIX systems

    • Including agent forwarding support on both the client and the server

  • Support for accessing keys managed by PuTTY’s Pageant agent on Windows

  • Support for accessing host keys via OpenSSH’s ssh-keysign

  • OpenSSH-style known_hosts file support

  • OpenSSH-style authorized_keys file support

  • Partial support for OpenSSH-style configuration files

  • Compatibility with OpenSSH “Encrypt then MAC” option for better security

  • Time and byte-count based session key renegotiation

  • Designed to be easy to extend to support new forms of key exchange, authentication, encryption, and compression algorithms

License

This package is released under the following terms:

Copyright (c) 2013-2025 by Ron Frederick <ronf@timeheart.net> and others.

This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies this distribution and is available at:

http://www.eclipse.org/legal/epl-2.0/

This program may also be made available under the following secondary licenses when the conditions for such availability set forth in the Eclipse Public License v2.0 are satisfied:

GNU General Public License, Version 2.0, or any later versions of that license

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later

For more information about this license, please see the Eclipse Public License FAQ.

Prerequisites

To use AsyncSSH 2.0 or later, you need the following:

  • Python 3.10 or later

  • cryptography (PyCA) 39.0 or later

Installation

Install AsyncSSH by running:

pip install asyncssh

Optional Extras

There are some optional modules you can install to enable additional functionality:

AsyncSSH defines the following optional PyPI extra packages to make it easy to install any or all of these dependencies:

bcrypt
fido2
ifaddr
gssapi
pkcs11
pyOpenSSL
pywin32

For example, to install bcrypt, fido2, gssapi, ifaddr, pkcs11, and pyOpenSSL on UNIX, you can run:

pip install 'asyncssh[bcrypt,fido2,gssapi,ifaddr,pkcs11,pyOpenSSL]'

To install bcrypt, fido2, ifaddr, pkcs11, pyOpenSSL, and pywin32 on Windows, you can run:

pip install 'asyncssh[bcrypt,fido2,ifaddr,pkcs11,pyOpenSSL,pywin32]'

Note that you will still need to manually install the libnettle library for UMAC support. Unfortunately, since liboqs and libnettle are not Python packages, they cannot be directly installed using pip.

Installing the development branch

If you would like to install the development branch of asyncssh directly from Github, you can use the following command to do this:

pip install git+https://github.com/ronf/asyncssh@develop

Mailing Lists

Three mailing lists are available for AsyncSSH:

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asyncssh-2.23.0.tar.gz (542.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asyncssh-2.23.0-py3-none-any.whl (375.7 kB view details)

Uploaded Python 3

File details

Details for the file asyncssh-2.23.0.tar.gz.

File metadata

  • Download URL: asyncssh-2.23.0.tar.gz
  • Upload date:
  • Size: 542.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for asyncssh-2.23.0.tar.gz
Algorithm Hash digest
SHA256 8c54760953c1f2cf282591bcba5c8c70efc48d645bbf26bd2307a9c66a0ed1a7
MD5 01f73436416625c9e1694973305336ae
BLAKE2b-256 eefdc34fe7e30838b4b9cc91903da26a62c6d33b673c731b3d951fcd70ab1889

See more details on using hashes here.

File details

Details for the file asyncssh-2.23.0-py3-none-any.whl.

File metadata

  • Download URL: asyncssh-2.23.0-py3-none-any.whl
  • Upload date:
  • Size: 375.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for asyncssh-2.23.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14108bfdaae17457f0c1841e883ad934271bbfdd46458aa4c4d0973451940ad0
MD5 954ee2799df65f12f1dbec198a22a4a4
BLAKE2b-256 ffb5b1a3979f4840d1271ca8e0978dbccfb18ad2d33b4ece85cf77122fb46e5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page