Robot Framework SSHLibrary

3.8.0 · active · verified Thu Apr 16

Robot Framework SSHLibrary is a test library for SSH and SFTP operations. It provides keywords for executing commands, interacting with interactive shells, transferring files and directories via SFTP, and asserting the existence of files and directories on remote machines. The library is operating system independent and currently supports Python 3.6 or newer (older versions like 3.8.0 also supported Python 2.7 and 3.4+). It maintains an active release cadence with regular updates and enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This example connects to a remote SSH server using environment variables for credentials, executes a simple `ls -l /tmp` command, logs the output, asserts a part of the output, and then closes the connection. Set `SSH_HOST`, `SSH_PORT`, `SSH_USERNAME`, and `SSH_PASSWORD` environment variables before running.

*** Settings ***
Documentation    Demonstrates SSHLibrary connection and command execution.
Library          SSHLibrary

*** Variables ***
${SSH_HOST}      ${OS_ENVIRONMENT_SSH_HOST}
${SSH_PORT}      ${OS_ENVIRONMENT_SSH_PORT}
${SSH_USERNAME}  ${OS_ENVIRONMENT_SSH_USERNAME}
${SSH_PASSWORD}  ${OS_ENVIRONMENT_SSH_PASSWORD}

*** Test Cases ***
Execute Remote Command
    [Tags]    SSH
    Open Connection    ${SSH_HOST}    port=${SSH_PORT}
    Login              ${SSH_USERNAME}    ${SSH_PASSWORD}
    ${output}=         Execute Command    ls -l /tmp
    Log To Console     Command Output: ${output}
    Should Contain     ${output}          total
    Close Connection

view raw JSON →