What is simplest way to set up a git server on my Linode?

Though I have been a git user since 2010, I have never run a git server. I now wish to run a git server on my linode. I am trying to determine the simplest way to get such a server up-and-running.

My objectives:

  1. This git server will be essentially non-public. It will host multiple repositories, whose primary usages will be:

a. Backup and version control for git repositories, some on my home desktop computer and some elsewhere on my linode, which currently have no remote. (For the purpose of getting started, I intend to use a remote-less repository already sitting on my linode as the first repository in the new server.)

b. Backup and version control for git repositories which I and a few colleagues intend to create. Those colleagues will have read/write access to designated repositories and will have to provide SSH keys for that access.

  1. I do not, at the current time, need a GUI view of the repositories on this server. Command-line access will suffice.

  2. I do not, at the current time, want anything as elaborate as GitLab as described at https://linode.com/docs/development/version-control/install-gitlab-on-ubuntu-18-04/.

  3. The websites I have already consulted with respect to this are:

a. https://git-scm.com/book/en/v1/Git-on-the-Server

b. https://www.linux.com/learn/how-run-your-own-git-server

Let's assume that I want to place this git server under /opt/git and that the permission on that directory currently are:

$ ls -ld /opt/git
drwxr-xr-x 2 root root 4096 Jul 18 16:02 /opt/git

I want to get the server up-and-running in the simplest possible way. Among my questions are:

  1. Do I need to create a 'git' user on my linode?

  2. Assuming I need to create a 'git' server, does it need its own SSH keys on the server?

  3. Is there any reason why I would need to create a 'git' user on my desktop? (Reference (b) above appears to suggest that I should do so, but I can't figure out why I would need that.)

  4. Should directories and files under /opt/git be owned by user 'git' or continue to be owned by 'root'?

  5. How does a call to my git server know where that server is located on my linode?

  • I would expect to configure the remote for a checkout from a repository on this server like this:
[remote "origin"]
    url = git://mydomain.net/myproject1.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    pushurl = ssh://jkeenan@mydomain.net/myproject1.git

So how would those calls find the server serving up myproject1 on mydomain.net?

I'm sure I'll have other questions, but I would appreciate any guidance you can provide on those above?

Thank you very much.
Jim Keenan

1 Reply

Hey there,

The simplest way to get Git running on your Linode is by utilizing our Getting Started with Git Guide. It offers you step-by-step instructions on configuring and using Git.

Git also hosts an excellent set of documentation with step-by-step instructions on everything from installing and configuring yur git server to advanced configurations and troubleshooting, here.

Do I need to create a 'git' user on my linode?

You will need to create a user on your git server which this guide reviews in more detail. If you create a single git user on the machine, you can ask every user who is to have write access to send you an SSH public key, and add that key to the ~/.ssh/authorized_keys file of your new git user. At that point, everyone will be able to access that machine via the git user. This doesn’t affect the commit data in any way – the SSH user you connect as doesn’t affect the commits you’ve recorded.

Assuming I need to create a 'git' server, does it need its own SSH keys on the server?

You'll want SSH keys added to the Linode for basic access for each user accessing the git server on your Linode. There won't be separate keys for the Linode and your git repo.

Is there any reason why I would need to create a 'git' user on my desktop? (Reference (b) above appears to suggest that I should do so, but I can't figure out why I would need that.)

You'll need a user on your local to Work with Remotes. A git user provides a common user to restrict server access to, rather than multiple users hosting keys of their own.

Should directories and files under /opt/git be owned by user 'git' or continue to be owned by 'root'?

Git will automatically add group write permissions to a repository properly if you run the git init command with the --shared option.

How does a call to my git server know where that server is located on my linode?

Your Git Commands help facilitate local and remote connection. this includes checking the Status of Files.

We hope that helps.

Sincerely,
Tara T
Linode Support Team

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct