cgi relay for python cgi script

Michael Ekstrand mekstran at scl.ameslab.gov
Tue Oct 4 15:11:44 EDT 2005


On Oct 4, 2005, at 2:35 AM, Amir Michail wrote:
> Is there an easy way to execute a python cgi script on a different
> machine from the cgi server?
>
> I could write my own server, but I was wondering if something is
> available that would allow me to use a cgi script as is without
> modification.

What I would try: Set up an SSH account for the CGI to run as on the 
other machine, and set up a passwordless SSH public/private key pair. 
Store the private key on the web server under the account used to run 
CGI programs.

Then write a small "stub" CGI that runs the other CGI via SSH. Not sure 
how environment variables will need to be transferred - SSH may have a 
way to set environment, or you may need a stub on both ends, or just 
build a SSH invocation that runs 'env' on the remote system. Your stub 
could be as simple as:

#!/bin/sh
ssh user at cgi.host.com /usr/bin/env HTTP_HOST="$HTTP_HOST" 
OTHER_ENV_VARS /my/cgi/script "$@"

Depending on your security  needs, you may need to do things with 
alternate shells for the CGI user account, etc., but that can be done. 
And it will probably also need some input sanitization, etc. so you 
aren't executing arbitrary commands.

-Michael




More information about the Python-list mailing list