I got this shell script from a blog about how to equip git with gitosis. But i got a “No such file or directory” error after running the script.
[git@209285 ~]$ sudo -H -u git gitosis-init < ~/id_rsa.pub Traceback (most recent call last): File "/usr/local/bin/gitosis-init", line 9, in <module> load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-init')() File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 24, in run return app.main() File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 38, in main self.handle_args(parser, cfg, options, args) File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 138, in handle_args user=user, File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 75, in init_admin_repository template=resource_filename('gitosis.templates', 'admin') File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/repository.py", line 63, in init close_fds=True, File "/usr/local/lib/python2.7/subprocess.py", line 522, in call return Popen(*popenargs, **kwargs).wait() File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
I am puzzled,as the man manual says that:
-H The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo does not modify HOME (see set_home and always_set_home in sudoers(5)).
,which is cited from linux manual.
The -H option just sets the HOME environment variable to the homedir of the target user as specified in passwd.
However i specified “/home/git” as homedir for git user in my /etc/passwd file.
apache:x:48:48:Apache:/var/www:/sbin/nologin git:x:100:101:git version control:/home/git:/bin/bash duanduan:x:101:500::/home/duanduan:/bin/bash
But why i still got this message? or was incorrect my comprehension of the description in manual?
Append for comments:
And it seems like before with specifying a absolute path.Maybe, it’s not the cause.
sudo -H -u git gitosis-init < /home/git/id_rsa.pub Traceback (most recent call last): File "/usr/local/bin/gitosis-init", line 9, in <module> load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-init')() File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 24, in run return app.main() File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 38, in main self.handle_args(parser, cfg, options, args) File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 138, in handle_args user=user, File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 75, in init_admin_repository template=resource_filename('gitosis.templates', 'admin') File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/repository.py", line 63, in init close_fds=True, File "/usr/local/lib/python2.7/subprocess.py", line 522, in call return Popen(*popenargs, **kwargs).wait() File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
Advertisement
Answer
I guess it is because ~
is expanded by bash before transferring to sudo
as a argument, why not try to specify a absolute path for you public key file?