Skip to content

Instantly share code, notes, and snippets.

@chrishuan9
Created February 8, 2019 14:19
Show Gist options
  • Save chrishuan9/9ac18d068ba2e08c69c8180af7c1cdd7 to your computer and use it in GitHub Desktop.
Save chrishuan9/9ac18d068ba2e08c69c8180af7c1cdd7 to your computer and use it in GitHub Desktop.
import asyncio, asyncssh, sys
async def run_client():
#async with asyncssh.connect('localhost',kex_algs=["diffie-hellman-group1-sha1"],known_hosts=None,username='ridgeline',password='47e4b27ad353033a6c2fc969a7beddaf',signature_algs=['ssh-dss']) as conn:
async with asyncssh.connect('10.28.8.1',kex_algs=['diffie-hellman-group-exchange-sha256','diffie-hellman-group-exchange-sha1','diffie-hellman-group1-sha1','diffie-hellman-group14-sha1','diffie-hellman-group14-sha256','diffie-hellman-group15-sha512','diffie-hellman-group16-sha512','diffie-hellman-group17-sha512','diffie-hellman-group18-sha512'],known_hosts=None,username='ridgeline',password='47e4b27ad353033a6c2fc969a7beddaf',signature_algs=['ssh-dss']) as conn:
result = await conn.run('ls', check=True)
print(result.stdout, end='')
def main():
try:
asyncio.get_event_loop().run_until_complete(run_client())
except (OSError, asyncssh.Error) as exc:
sys.exit('SSH connection failed: ' + str(exc))
if __name__ == '__main__':
main()
import asyncio, asyncssh, sys
async def run_client():
#async with asyncssh.connect('localhost',kex_algs=["diffie-hellman-group1-sha1"],known_hosts=None,username='ridgeline',password='47e4b27ad353033a6c2fc969a7beddaf',signature_algs=['ssh-dss']) as conn:
async with asyncssh.connect('10.28.8.1',kex_algs=['diffie-hellman-group-exchange-sha256','diffie-hellman-group-exchange-sha1','diffie-hellman-group1-sha1','diffie-hellman-group14-sha1','diffie-hellman-group14-sha256','diffie-hellman-group15-sha512','diffie-hellman-group16-sha512','diffie-hellman-group17-sha512','diffie-hellman-group18-sha512'],known_hosts=None,username='ridgeline',password='47e4b27ad353033a6c2fc969a7beddaf',signature_algs=['ssh-dss']) as conn:
result = await conn.run('ls', check=True)
print(result.stdout, end='')
def main():
try:
asyncio.get_event_loop().run_until_complete(run_client())
except (OSError, asyncssh.Error) as exc:
sys.exit('SSH connection failed: ' + str(exc))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment