Git

Git is a free and open source distributed version control system which is installed on all Opalstack servers.

You can use the git command while logged in to your Opalstack server as one of your shell users. For example, to clone a Git repository from GitHub:

git clone https://github.com/xxxx/yyyy.git

The repository will be cloned into a subdirectory yyyy of the current directory.

Gitea

Gitea is a self-hosted Git service, written in Go, which can serve Git repositories with associated issue trackers and wikis.

Installing Gitea

  1. To install a Gitea application follow our general instructions for adding applications and select "Gitea" as the application type in step 5.

  2. Create a site to serve your Gitea application - see Managing Sites for instructions on how to create a site.

  3. SSH into your shell user's server and update /home/username/app/appname/custom/conf/app.ini to set the DOMAIN and ROOT_URL parameters to use your site's domain.

  4. Restart the app:

    /home/username/app/appname/stop
    /home/username/app/appname/start
    
  5. Log in to your Gitea site and set your email address to the address that you want to use with your Gitea profile.

Using SSH Keys with Gitea

Gitea supports the use of SSH keys to enable secure password-less access to your Git repositories.

If you are already using SSH keys to access your shell account, you'll need to create a new key for Gitea.

To set it up:

  1. Open your terminal application on your local system and generate a new key by executing the following commands, replacing mydomain_com with the domain name and suffix assigned to your Gitea site:

    mkdir -p ~/.ssh
    touch ~/.ssh/config
    chmod 600 ~/.ssh/config
    chmod 700 ~/.ssh
    ssh-keygen -t rsa -f $HOME/.ssh/gitea_mydomain_com_rsa -N ""
    
  2. Edit your local ~/.ssh/config with the following contents, replacing gitea.mydomain.com with the domain assigned to your Gitea site and gitea_mydomain_com_rsa with the name of the key you created in step 1:

    Host gitea.mydomain.com
      IdentityFile ~/.ssh/gitea_mydomain_com_rsa
      IdentitiesOnly yes
    
  3. Run the following command to output the public key to your terminal:

    cat ~/.ssh/gitea_mydomain_com_rsa.pub
    

    Select the output and copy it to your clipboard.

  4. Log into your Gitea site and go to /user/settings/keys.

    There, locate the "Manage SSH Keys" box and click the blue "Add Key" button in the right-hand corner.

  5. Enter a name for your key, then paste the output from step 3 into the content box.

  6. Save the key by clicking the green "Add Key" button below the form.

At this point you should be able to access your repos over SSH with no password with your Gitea app's shell user. For example:

git clone myshelluser@gitea.mydomain.com:username/reponame.git