Sweety Sweety - 1 month ago 9
Apache Configuration Question

Python CGI script running from web URL creates directory with www-data user

I am trying to run Python CGI script. The issue I am facing is, I need to create a directory and clone repo from git with my username.

import commands, os
print "Content-type: text/html\n"
print "\n\n"
print "<html><body>"
commands.getoutput("rm -rf fresh-cloned")
commands.getoutput("mkdir fresh-cloned")
print commands.getoutput("pwd")
commands.getoutput("git clone <> -b <>")

But somehow, when I run the script from web URL : "http://ip_adr/webtest/webgui.py", I see the directory being created with www-data user rather than with my username. Due to that git clone won't work as ssh key is added in Stash for my username only.

drwxr-xr-x 2 www-data www-data 4.0K Nov 28 16:59 fresh-cloned

How can I resolve this issue? Is it possible to change the user to my username while running script from web URL?


I was able to resolve the issue by changing following line in "/etc/passwd"


I created/updated user, gave required permissions, created ssh key and added in stash, it is working now. Thanks!