Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • See all Red Hat products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Red Hat OpenShift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • See all technologies
    • Programming languages & frameworks

      • Java
      • Python
      • JavaScript
    • System design & architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer experience

      • Productivity
      • Tools
      • GitOps
    • Automated data processing

      • AI/ML
      • Data science
      • Apache Kafka on Kubernetes
    • Platform engineering

      • DevOps
      • DevSecOps
      • Red Hat Ansible Automation Platform for applications and services
    • Secure development & architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & cloud native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • See all learning resources

    E-books

    • GitOps cookbook
    • Podman in action
    • Kubernetes operators
    • The path to GitOps
    • See all e-books

    Cheat sheets

    • Linux commands
    • Bash commands
    • Git
    • systemd commands
    • See all cheat sheets

    Documentation

    • Product documentation
    • API catalog
    • Legacy documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore the Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

New LibSSH connection plug-in for Ansible replaces Paramiko

February 13, 2026
Ganesh Nalawade
Related topics:
Automation and managementLinuxSecurity
Related products:
Red Hat Ansible Automation PlatformRed Hat Enterprise Linux

    As Red Hat Ansible Automation Platform expands its footprint with a growing customer base, security continues to be an important aspect of organizations' overall strategy. Red Hat regularly reviews and enhances the foundational codebase to follow better security practices. As part of this effort, we introduce the libssh connection plug-in that uses the libssh library. Red Hat Ansible Network Automation users can now achieve industrial scale performance while maintaining strict adherence to FIPS 140 readiness standards and fulfilling critical requirements for federal security compliance as outlined in DISA STIG ID: 1057.

    Network SSH connection basics

    Since most network appliances don't support or have limited capability for the local execution of a third-party software, the network modules are not copied to the remote host unlike Linux hosts. Instead, they run on the control node. Hence, the network can't use the typical Ansible SSH connection plug-in used with a Linux host. Due to this behavior, performance of the underlying SSH subsystem is critical (Figure 1). Not only does the new LibSSH connection plug-in enable FIPS readiness, but it is more performant than the existing Paramiko SSH subsystem.

    This diagram shows an Ansible Network Automation connection flow.
    Figure 1: This Ansible module execution model compares network devices and Linux/Windows hosts.

    The top level network_cli connection plug-in, provided by the ansible.netcommon collection, specifically the ansible.netcommon.network_cli, provides an SSH based connection to the network appliance. Then it calls the ansible.builtin.paramiko_ssh connection plug-in that depends on the Paramiko Python library to initialize the session between the control node and the remote host. After that, it creates a pseudo terminal (PTY) to send commands from the control node to the network appliance and receive the responses.

    Why replace Paramiko?

    The primary reason to replace the Paramiko library is that it doesn't guarantee FIPS readiness, and thus limits the Ansible Automation Platform network capability to run in environments that mandate FIPS mode enablement. Paramiko also isn't the speediest of connection plug-ins, so that can be enhanced. Therefore, you can now swap the new ansible.netcommon.libssh connection plug-in for Paramiko. The ansible.netcommon collection now contains this by default, and you can use it for testing purposes until the codebase becomes more stable (currently in Technology Preview).

    Comparing the connection flow to the previous flow, the top level network_cli connection plug-in that is provided by the ansible.netcommon collection, specifically the ansible.netcommon.network_cli still provides an SSH based connection to the network appliance. It in turn calls the ansible.netcommon.libssh connection plug-in that depends on the ansible-pylibssh Python library to initialize the session between control node and the remote host. This python library is essentially a Python wrapper on top of the libssh C library. It then creates pseudo terminals (PTY) over SSH using Python.

    Switching Ansible Playbooks to use LibSSH

    With the ansible.netcommon collection version 1.0.0, a new configuration parameter within ansible.netcommon.network_cli connection plug-in was added, which allows for you to set the ssh_type to either libssh or paramiko. 

    If the value of the configuration parameter is set to libssh, it will use the ansible.netcommon.libssh connection plug-in, which in turn uses the ansible-pylibssh Python library that supports FIPS readiness. If the value is set to paramiko, it will continue to use the default ansible.builtin.paramiko connection plug-in that relies on the paramiko Python library. 

    Again, the default value is set to paramiko, but in the future plans are to change the default to libssh.

    Installing and configuring LibSSH

    To utilize the LibSSH plug-in, you must first install the ansible-pylibssh Python library from PyPI using the following command:

    pip install ansible-pylibssh

    The current PyPI installation method bundles the correct version of libssh library and its dependencies as platform-specific wheels that don't rely on any OS-level libraries in runtime.

    Future plans include creation, publishing, and maintenance of stand-alone RPM and DEB packages for the ansible-pylibssh library that you can install with well-known Linux package managers. These will install the required system libssh version and its dependencies on the control node. Red Hat Enterprise Linux 8.1 and later contains the proper libssh package version and its dependencies.

    The current primary use case for using LibSSH with Ansible Automation Platform is for connecting to network devices. Connecting to other types of endpoints such as Linux will be officially enabled at a later date.

    How to use LibSSH in Ansible Playbooks

    There are two methods to using LibSSH in Ansible Playbooks.

    Method 1: You can set the ssh_type configuration parameter to use libssh in the active ansible.cfg file of your project as follows.

    [persistent_connection]
    ssh_type = libssh

    Method 2: Set the ANSIBLE_NETWORK_CLI_SSH_TYPE environment variable as follows.

    $export ANSIBLE_NETWORK_CLI_SSH_TYPE=libssh

    Method 3:  Set the ansible_network_cli_ssh_type parameter to libssh within your playbook at the play level.

    Note: This setting can be made at the individual task level, but only if the connection to the remote network device is not already established. That is, if the first task uses paramiko, then all subsequent tasks in the play must use paramiko even if libssh is specified in any subsequent tasks.

    Troubleshooting LibSSH connections

    To quickly verify the libssh transport is set correctly, you can run the following playbook using the ansible-playbook command line with the verbose flag -vvvv. Before running, ensure the inventory file is set correctly.

    This example playbook uses the cisco.ios collection and must first be installed from Ansible Galaxy or Ansible Automation Platform on your control node.

    - hosts: "changeme"
      gather_facts: no
      connection: ansible.netcommon.network_cli
      vars:
        ansible_network_os: cisco.ios.ios
        ansible_user: "changeme"
        ansible_password: "changeme"
        ansible_network_cli_ssh_type: libssh
      tasks:
      - name: run show version command
        ansible.netcommon.cli_command:
          command: show version
    
      - name: run show interface command
        ansible.netcommon.cli_command:
           command: show interfaces

    https://gist.github.com/ganeshrn/78149adca85c809b69ed1b5f5262844c

    In the output verbose logs, you should see the line "ssh type is set to libssh" displayed on the console, which confirms the configuration is set correctly.

    Next steps

    Start testing your Ansible Playbooks by setting the configuration to use the ansible-pylibssh library. Help with performance profiling of your existing playbook of ansible-pylibssh library with respect to paramiko library. Get involved with the ansible-pylibssh project.

    Related Posts

    • Multi-homed inventory management with Ansible Automation Platform

    • What's new in Ansible Automation Platform 2.6

    • Multicluster authentication with Ansible Automation Platform

    • Protecting virtual machines from storage and secondary network node failures

    Recent Posts

    • New LibSSH connection plug-in for Ansible replaces Paramiko

    • How to build an image mode pipeline with GitLab

    • Build a zero trust environment with Red Hat Connectivity Link

    • Guide to configuring multiple authentication providers in Developer Hub

    • Agentic AI: Design reliable workflows across the hybrid cloud

    What’s up next?

    SSH into remote machines

    SSH into remote machines using Ansible cheat sheet

    Deepankar Jain
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue