Esempio n. 1
0
    d = endpoint.connect(factory)
    d.addCallback(lambda protocol: protocol.finished)

    # trigger
    # Source: https://trigger.readthedocs.io/en/latest/examples.html#execute-commands-asynchronously-using-twisted
    from trigger.netdevices import NetDevices
    nd = NetDevices()
    dev = nd.find('ssh.example.com')
    dev.execute([command])

    # parallel-ssh
    # Source: https://github.com/ParallelSSH/parallel-ssh
    from pssh.clients import SSHClient

    client = SSHClient('ssh.example.com')
    host_out = client.run_command(command)

    # scrapli (can use paramiko, ssh2, asyncssh as transport)
    # Source: https://github.com/carlmontanari/scrapli
    from scrapli import Scrapli

    conn = Scrapli(host='ssh.example.com' auth_username="******", auth_password="******")
    conn.open()
    conn.send_command(command)

    # redexpect (based on ssh2-python)
    # Source: https://github.com/Red-M/RedExpect/blob/master/examples/run_whoami.py
    import redexpect
    expect = redexpect.RedExpect()
    expect.login(hostname="ssh.example.com", username="******", password="******", allow_agent=True, timeout=1.5)
    expect.command(command)