简体   繁体   中英

Using python modules over Paramiko (SSH)

I have recently installed and used Paramiko to connect via SSH to another computer in my domain.

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.

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.

eg

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

which I then read in via SSH and look at what the result is. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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