From 7939805687e75f8a46cd6c43a80e9fb3db88da81 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Mon, 7 Mar 2022 21:18:44 +0000 Subject: Add Installing Docker on Arch Linux --- .../git/2021-05-29/setting-up-a-self-host-git-server/index.html | 6 +++--- www/posts/git/2021-06-13/backing-up-a-git-repository/index.html | 2 +- www/posts/git/atom.xml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'www/posts/git') diff --git a/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html b/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html index 662017b..39c89dd 100644 --- a/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html +++ b/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html @@ -18,7 +18,7 @@ -

Setting up a Self Hosted Git Server

Sat 29th May 2021 By David T. Sadler.

I've always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.

Installing Git

Since its an Ubuntu server installing git is as simple as.

$ sudo apt install git-core

Creating a User

The git user will serve two purposes.

$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git

Setting up SSH

On my local machine git will use ssh to connect to the remote server as the git user. In order to do this I will need to copy my public ssh key to the git user account.

The below commands create the required .ssh directory and authorized_keys file with the correct permissions.

$ sudo mkdir /home/git/.ssh
+        

Setting up a Self Hosted Git Server

Sat 29th May 2021 By David T. Sadler.

I've always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.

  • Installing git.
  • Creating a git user.
  • Setting up ssh so that I can log into the sever securely as the git user.
  • Creating a test repository on the server.
  • Creating a test project on my local machine.
  • Pushing the test project to the git sever.

Installing Git

Since its an Ubuntu server installing git is as simple as.

$ sudo apt install git-core

Creating a User

The git user will serve two purposes.

  • The repositories will be stored in the user's home directory.
  • The user account will contain the public ssh keys of remote users that can access the repositories.
$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git
  • --system Creates a system user user. Not strictly required but since this is not a normal user account I prefer to use this option.
  • --shell /usr/bin/git-shell Restrict the git user to only git related activities. This also prevents remote users from obtaining a shell by logging in via ssh. Note that git-shell does not prevent normal git operations, such as pull and push, from working over ssh.
  • --group Creates a group that is the same name as the user.
  • --disabled-password Prevent logging in with a password. The use of ssh keys is still allowed.
  • --home /home/git The home directory for the user.

Setting up SSH

On my local machine git will use ssh to connect to the remote server as the git user. In order to do this I will need to copy my public ssh key to the git user account.

The below commands create the required .ssh directory and authorized_keys file with the correct permissions.

$ sudo mkdir /home/git/.ssh
 $ sudo chown git:git /home/git/.ssh
 $ sudo chmod 700 /home/git/.ssh
 $ sudo touch /home/git/.ssh/authorized_keys
@@ -41,10 +41,10 @@ $ cd test
 $ git init
 $ touch readme
 $ git add .
-$ git commit -m 'Initial commit'
+$ git commit -m 'Initial commit'
 $ git remote add origin git@git.davidtsadler.com:test.git
 $ git push origin main

I can also test that I can clone the repository.

rm -rf test
-git clone git@git.davidtsadler.com:test.git

Links

Git - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
+git clone git@git.davidtsadler.com:test.git

Links

Git - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
diff --git a/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html b/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html index 4c0c090..655f536 100644 --- a/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html +++ b/www/posts/git/2021-06-13/backing-up-a-git-repository/index.html @@ -34,7 +34,7 @@ tar -czf $BACKUP_FILE $REPOSITORIES find $BACKUP_FILES -mtime +3 -delete -exit 0

All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.

This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.

0 3 * * * /usr/bin/backup_repositories > /dev/null 2>&1

It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running.

Links

2021-05-29 - Setting up a Self Hosted Git ServerGit - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage. +exit 0

All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.

This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.

0 3 * * * /usr/bin/backup_repositories > /dev/null 2>&1

It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running.

Links

2021-05-29 - Setting up a Self Hosted Git ServerGit - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage. diff --git a/www/posts/git/atom.xml b/www/posts/git/atom.xml index 0ada83f..c3b0e4b 100644 --- a/www/posts/git/atom.xml +++ b/www/posts/git/atom.xml @@ -28,7 +28,7 @@ tar -czf $BACKUP_FILE $REPOSITORIES find $BACKUP_FILES -mtime +3 -delete -exit 0</code></pre><p>All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.</p><p>This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.</p><pre><code class="cron">0 3 * * * /usr/bin/backup_repositories &gt; /dev/null 2&gt;&amp;1</code></pre><p>It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won't be suitable for restoring. However its fine for my purposes since I'm the only user and it's unlikely that I will be making changes during the time the backup is running.</p><h3>Links</h3><a href="/posts/git/2021-05-29/setting-up-a-self-host-git-server/">2021-05-29 - Setting up a Self Hosted Git Server</a><a href="/posts/git/">Git - Read More Posts.</a><p>I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.</p><a href="mailto:david@davidtsadler.com">Email david@davidtsadler.com</a><h3>License</h3><a href="https://creativecommons.org/licenses/by-sa/4.0/">The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</a><p>Copyright © 2021 David T. Sadler.</p><a href="/">Return to Homepage.</a> +exit 0</code></pre><p>All it does it tar and gzip any .git directories found under /home/git. It also removes any backups that are more than three days old.</p><p>This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.</p><pre><code class="cron">0 3 * * * /usr/bin/backup_repositories &gt; /dev/null 2&gt;&amp;1</code></pre><p>It is important to know that this backup strategy is far from ideal for repositories that are heavily used as you run the high risk of trying to backup a repository as users are pushing to it. As git updates a repository in two phases this will lead to a backup that may not contain all the data and so won&#039;t be suitable for restoring. However its fine for my purposes since I&#039;m the only user and it&#039;s unlikely that I will be making changes during the time the backup is running.</p><h3>Links</h3><a href="/posts/git/2021-05-29/setting-up-a-self-host-git-server/">2021-05-29 - Setting up a Self Hosted Git Server</a><a href="/posts/git/">Git - Read More Posts.</a><p>I don&#039;t have comments as I don&#039;t want to manage them. You can however contact me at the below address if you want to.</p><a href="mailto:david@davidtsadler.com">Email david@davidtsadler.com</a><h3>License</h3><a href="https://creativecommons.org/licenses/by-sa/4.0/">The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</a><p>Copyright © 2021 David T. Sadler.</p><a href="/">Return to Homepage.</a> Setting up a Self Hosted Git Server https://davidtsadler.com/posts/git/2021-05-29/setting-up-a-self-host-git-server/ @@ -36,7 +36,7 @@ exit 0</code></pre><p>All it does it tar and gzip any .git dir David T. Sadler. 2021-05-29T12:00:00Z 2021-05-29T12:00:00Z - <h1>Setting up a Self Hosted Git Server</h1><blockquote>Sat 29th May 2021 By David T. Sadler.</blockquote><p>I've always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.</p><ul><li>Installing git.</li><li>Creating a git user.</li><li>Setting up ssh so that I can log into the sever securely as the git user.</li><li>Creating a test repository on the server.</li><li>Creating a test project on my local machine.</li><li>Pushing the test project to the git sever.</li></ul><h2>Installing Git</h2><p>Since its an Ubuntu server installing git is as simple as.</p><pre><code class="shell">$ sudo apt install git-core</code></pre><h2>Creating a User</h2><p>The git user will serve two purposes.</p><ul><li>The repositories will be stored in the user's home directory.</li><li>The user account will contain the public ssh keys of remote users that can access the repositories.</li></ul><pre><code class="shell">$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git</code></pre><ul><li>--system Creates a system user user. Not strictly required but since this is not a normal user account I prefer to use this option.</li><li>--shell /usr/bin/git-shell Restrict the git user to only git related activities. This also prevents remote users from obtaining a shell by logging in via ssh. Note that git-shell does not prevent normal git operations, such as pull and push, from working over ssh.</li><li>--group Creates a group that is the same name as the user.</li><li>--disabled-password Prevent logging in with a password. The use of ssh keys is still allowed.</li><li>--home /home/git The home directory for the user.</li></ul><h2>Setting up SSH</h2><p>On my local machine git will use ssh to connect to the remote server as the git user. In order to do this I will need to copy my public ssh key to the git user account.</p><p>The below commands create the required .ssh directory and authorized_keys file with the correct permissions.</p><pre><code class="shell">$ sudo mkdir /home/git/.ssh + <h1>Setting up a Self Hosted Git Server</h1><blockquote>Sat 29th May 2021 By David T. Sadler.</blockquote><p>I&#039;ve always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.</p><ul><li>Installing git.</li><li>Creating a git user.</li><li>Setting up ssh so that I can log into the sever securely as the git user.</li><li>Creating a test repository on the server.</li><li>Creating a test project on my local machine.</li><li>Pushing the test project to the git sever.</li></ul><h2>Installing Git</h2><p>Since its an Ubuntu server installing git is as simple as.</p><pre><code class="shell">$ sudo apt install git-core</code></pre><h2>Creating a User</h2><p>The git user will serve two purposes.</p><ul><li>The repositories will be stored in the user&#039;s home directory.</li><li>The user account will contain the public ssh keys of remote users that can access the repositories.</li></ul><pre><code class="shell">$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git</code></pre><ul><li>--system Creates a system user user. Not strictly required but since this is not a normal user account I prefer to use this option.</li><li>--shell /usr/bin/git-shell Restrict the git user to only git related activities. This also prevents remote users from obtaining a shell by logging in via ssh. Note that git-shell does not prevent normal git operations, such as pull and push, from working over ssh.</li><li>--group Creates a group that is the same name as the user.</li><li>--disabled-password Prevent logging in with a password. The use of ssh keys is still allowed.</li><li>--home /home/git The home directory for the user.</li></ul><h2>Setting up SSH</h2><p>On my local machine git will use ssh to connect to the remote server as the git user. In order to do this I will need to copy my public ssh key to the git user account.</p><p>The below commands create the required .ssh directory and authorized_keys file with the correct permissions.</p><pre><code class="shell">$ sudo mkdir /home/git/.ssh $ sudo chown git:git /home/git/.ssh $ sudo chmod 700 /home/git/.ssh $ sudo touch /home/git/.ssh/authorized_keys @@ -59,9 +59,9 @@ $ cd test $ git init $ touch readme $ git add . -$ git commit -m 'Initial commit' +$ git commit -m &#039;Initial commit&#039; $ git remote add origin git@git.davidtsadler.com:test.git $ git push origin main</code></pre><p>I can also test that I can clone the repository.</p><pre><code class="shell">rm -rf test -git clone git@git.davidtsadler.com:test.git</code></pre><h3>Links</h3><a href="/posts/git/">Git - Read More Posts.</a><p>I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.</p><a href="mailto:david@davidtsadler.com">Email david@davidtsadler.com</a><h3>License</h3><a href="https://creativecommons.org/licenses/by-sa/4.0/">The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</a><p>Copyright © 2021 David T. Sadler.</p><a href="/">Return to Homepage.</a> +git clone git@git.davidtsadler.com:test.git</code></pre><h3>Links</h3><a href="/posts/git/">Git - Read More Posts.</a><p>I don&#039;t have comments as I don&#039;t want to manage them. You can however contact me at the below address if you want to.</p><a href="mailto:david@davidtsadler.com">Email david@davidtsadler.com</a><h3>License</h3><a href="https://creativecommons.org/licenses/by-sa/4.0/">The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.</a><p>Copyright © 2021 David T. Sadler.</p><a href="/">Return to Homepage.</a> \ No newline at end of file -- cgit v1.2.3-13-gbd6f