-
Prepare remote server
# yum -y install git # useradd -c "GIT User" -s /usr/bin/git-shell git # mkdir ~git/.ssh # touch ~git/.ssh/authorized_keys # chown git. ~git/.ssh ~git/.ssh/authorized_keys # chmod 750 ~git/.ssh # chmod 600 ~git/.ssh/authorized_keys
-
Create a priv/pub key pair (if not already)
# ssh-keygen
-
Add the pub key to the git user's authorized_keys
# cat id_rsa.pub >> ~git/.ssh/authorized_keys
-
Create new repository on the server
# sudo -u git bash $ cd $ mkdir repos $ cd repos $ git init --bare newrepo.git
-
Clone the repo on the local user and start commiting
$ git clone [email protected]:repos/newrepo.git $ cd newrepo $ touch README $ git add README $ git commit -m "Initial checkin" $ git push origin master
-
Create
simeplehttp
service unit file# cat > /usr/lib/systemd/system/simplehttp.service << EOF [Unit] Description=Python based SimpleHTTPServer for git repos After=network.target [Service] Type=simple User=git Group=git WorkingDirectory=/home/git/repos ExecStart=/usr/bin/python -m SimpleHTTPServer 8000 Restart=on-abort [Install] WantedBy=multi-user.target EOF
-
Open firewall and enable+start the service
# firewall-cmd --add-port 8000/tcp # firewall-cmd --add-port 8000/tcp --permanent # systemctl daemon-reload # systemctl enable simplehttp # systemctl start simplehttp
-
Allow the 'dumb' git client to discover repository reference (this should be done for all repos)
# sudo -u git bash $ cd $ cd repos/newrepo.git $ git update-server-info $ mv hooks/post-update.sample hooks/post-update
-
Clone the repo unathenticated via HTTP as:
$ git clone http://server.example.com:8000/newrepo.git
-
Enable optional repo
# subscription-manager repos --enable rhel-7-server-optional-rpms
-
Install
git-daemon
package# yum install git-deamon
-
Create
git-daemon
service unit file (note the--export-all
param to export all repos without creatingrepo.git/git-daemon-export-ok
)# cat > /usr/lib/systemd/system/git-daemon.service << EOF [Unit] Description=Start Git Daemon [Service] ExecStart=/usr/bin/git daemon --reuseaddr --export-all --base-path=/home/git/repos/ /home/git/repos/ Restart=always RestartSec=500ms StandardOutput=syslog StandardError=syslog SyslogIdentifier=git-daemon User=git Group=git [Install] WantedBy=multi-user.target EOF
-
Open firewall and enable+start the service
# firewall-cmd --add-port 9418/tcp # firewall-cmd --add-port 9418/tcp --permanent # systemctl daemon-reload # systemctl enable git-daemon # systemctl start git-daemon
-
Clone the repo unathenticated as:
$ git clone git://server.example.com/newrepo.git