use paramiko to connect remote server and execute command

Posted otfsenter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了use paramiko to connect remote server and execute command相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env python

import sys, paramiko

hostname = ‘‘
password = ‘‘
command = ‘ls‘

username = ""
port = 22

try:
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy)

    client.connect(hostname, port=port, username=username, password=password)

    stdin, stdout, stderr = client.exec_command(command)
    print(stdout.read(), end=‘‘)

finally:
    client.close()

以上是关于use paramiko to connect remote server and execute command的主要内容,如果未能解决你的问题,请参考以下文章

paramiko__摘抄

How To Connect Using A Sqlplus Preliminary Connect

Mycat SqlServer Do not have slave connection to use, use master connection instead

paramiko 使用总结(SSH 操作远端机器)

[React] Refactor a connected Redux component to use Unstated

ERROR: Unable to connect to database using user ogg. Please check privileges.