简体   繁体   English

使用Python模块的paramiko以上(SSH)

[英]Using python modules over Paramiko (SSH)

I have recently installed and used Paramiko to connect via SSH to another computer in my domain. 我最近安装并使用Paramiko通过SSH连接到我域中的另一台计算机。

What I originally wanted to do was to connect and run a python module on the remote computer over SSH, but now I realise that SSH only provides limited functionality so calling the module isn't possible. 我最初想要做的是通过SSH在远程计算机上连接并运行python模块,但是现在我意识到SSH仅提供有限的功能,因此无法调用该模块。

I know I can call a script on the remote server and run that as a way of getting around this problem, but I was not sure about the security implications of doing this. 我知道我可以在远程服务器上调用脚本并运行它作为解决此问题的一种方法,但是我不确定这样做的安全性。 Also, of getting a result from the script. 另外,从脚本获得结果。 At the moment I am looking for the result using a print statement from the script and looking at it by reading the lines from stdout. 目前,我正在使用脚本中的打印语句来查找结果,并通过读取stdout中的行来查找结果。

eg 例如

If x:
    print "Yes"
else:
    print "No"

which I then read in via SSH and look at what the result is. 然后我通过SSH读取了一下,看看结果如何。 Is this a stupid way of doing it or am I missing a much more obvious / better way of knowing what the result is from my script? 这是一种愚蠢的做法,还是我缺少一种更明显/更好的方法来了解脚本的结果?

For something simple, your method works fine. 对于简单的事情,您的方法可以正常工作。 If you need something more complex, you might want to look at something that lets you do RMI , like Pyro . 如果您需要更复杂的内容,则可能需要查看可以执行RMI ,例如Pyro

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM