通过ssh在远程计算机上运行python脚本

通过ssh在远程计算机上运行python脚本,python,python-2.7,python-3.x,cygwin,paramiko,Python,Python 2.7,Python 3.x,Cygwin,Paramiko,远程机器已安装Cygwin,我已完成 $echo "PATH=\$PATH:/cygdrive/c/Python27" >> .bash_profile then, source .bash_profile (after doing this I am able to run a Python script from cygwin terminal). 现在,通过安装在笔记本电脑中的Pyscripter,我正试图通过paramiko在远程机器上运行hello_world: impo

远程机器已安装Cygwin,我已完成

$echo "PATH=\$PATH:/cygdrive/c/Python27" >> .bash_profile
then, source .bash_profile (after doing this I am able to run a Python script from cygwin terminal).
现在,通过安装在笔记本电脑中的Pyscripter,我正试图通过paramiko在远程机器上运行hello_world:

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect('135.24.237.167',username = 'cyg_server',password = 'force')

stdin,stdout,stderr = ssh.exec_command("/cygdrive/c/Python27/python /cygdrive/c/cygwin64/home/hello_world.py")

##But I get the following error:

stderr.readlines()

[u"C:\\Python27\\python.exe: can't open file '/cygdrive/c/cygwin64/home/hello_world.py': [Errno 2] No such file or directory\r\n"]

请帮忙。

我相信帕拉米科太生了。尝试使用织物

示例代码为:

from fabric.api import *

env.key_filename = /path/to/your/pem/file

def mem_usage():
   run('free -m')

execute(mem_usage, host="user@IP_or_hostname")
或者,如果您没有pem文件,您可以离开该行,并在提示时输入密码