![](/img/trans.png)
[英]Start a script on a remote machine through ssh with python - but in reverse?
[英]Running a python script on a remote machine through ssh
遠程計算機已安裝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文件,則可以保留該行,僅在出現提示時輸入密碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.