Skip to content

SSH connection failed: SSH connection closed #227

@marcosurbanski

Description

@marcosurbanski

Hi Ron i'm try to execute a list in for, but ssh connection return closed in a cisco router whats wrong ? when i start a single command i receive success return, another question how a i get all data output include banner, hostname, etc.

import asyncio, asyncssh, subprocess, sys

@asyncio.coroutine
async def run_client():
    async with asyncssh.connect(hostname='', known_hosts=None, username='', password='', client_keys=None ) as conn:
        local_proc = subprocess.Popen('', bufsize=1024, shell=True, stdout=subprocess.PIPE)
        var = ''
        cmd = ['sh cable modem summ', 'sh version', 'sh users']
        for p in cmd:
            remote_result = await conn.run(p + '\r\n', stdin=local_proc.stdout.read())
            print (remote_result.stdout)

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


Thanks,
Marcos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions