15 lines
531 B
Python
15 lines
531 B
Python
|
|
import asyncio
|
||
|
|
import asyncssh
|
||
|
|
|
||
|
|
async def main():
|
||
|
|
async with asyncssh.connect(
|
||
|
|
"132.243.17.164", port=2292, username="dimon",
|
||
|
|
password="123456789987654321", known_hosts=None,
|
||
|
|
) as conn:
|
||
|
|
r = await conn.run("echo '123456789987654321' | sudo -S id 2>/dev/null")
|
||
|
|
print("sudo id:", r.stdout.strip(), "rc:", r.returncode)
|
||
|
|
r = await conn.run("which docker; docker --version 2>/dev/null; echo '---'; nproc; free -m | head -2; df -h / | tail -1")
|
||
|
|
print(r.stdout)
|
||
|
|
|
||
|
|
asyncio.run(main())
|