Remote run shell through python

原文引用 大专栏  https://www.dazhuanlan.com/2019/08/26/5d6339d934930/


项目地址:https://github.com/seiferteric/telepythy

可以通过ssh调用远程机器的shell,大概示例:

from telepythy import Remote

h = Remote('localhost')


def getfile(filename="/etc/hosts"):
    return open(filename).read()


try:
    print(h.run(getfile))
    h.close()
except Exception as e:
    print("Handled Exception...")
    print(e)

猜你喜欢

转载自www.cnblogs.com/petewell/p/11411127.html