问题
Let's say I'm administrating a gitolite server. Is it possible to see the IP address of a user who cloned or pushed to my hosted repository? I have a custom POST_GIT
trigger installed that reads in .gitolite/logs
but logs don't contain IP addresses.
Any advice is much appreciated.
回答1:
It might depend on your Gitolite version.
In my .gitolite/logs
(gitolite 3.5+) , I do see the IP:
2014-09-29.07:38:59 19273 ssh ARGV=aUserName SOC=git-upload-pack 'aRepoName1' FROM=128.20x.xxx.xxx
2014-09-29.07:38:59 19274 ssh ARGV=aUserName SOC=git-upload-pack 'aRepoName2' FROM=128.20x.xxx.xxx
(also valid for http connections, not just ssh ones)
The src/gitolite-shell does include the IP:
gl_log( 'ssh', "ARGV=" . join( ",", @ARGV ), "SOC=" . ( $ENV{SSH_ORIGINAL_COMMAND} || '' ), "FROM=$ip" );
Introduced/updated in commit 906ed4c (for gitolite 3.04+, June 2012)
来源:https://stackoverflow.com/questions/26093734/gitolite-how-to-get-user-ip-address-who-clone-or-push-to-git