I'm not sure how to do it "the right way" but you may have a look at Paramiko, it's a python library that helps you implement your own SSH server (easily).
maybe you can build your own wrapper that calls a subprocess.
maybe you can build your own wrapper that calls a subprocess.