summaryrefslogtreecommitdiff
path: root/www/posts/git/atom.xml
diff options
context:
space:
mode:
Diffstat (limited to 'www/posts/git/atom.xml')
-rw-r--r--www/posts/git/atom.xml8
1 files changed, 4 insertions, 4 deletions
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&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;cron&quot;&gt;0 3 * * * /usr/bin/backup_repositories &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;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.&lt;/p&gt;&lt;h3&gt;Links&lt;/h3&gt;&lt;a href=&quot;/posts/git/2021-05-29/setting-up-a-self-host-git-server/&quot;&gt;2021-05-29 - Setting up a Self Hosted Git Server&lt;/a&gt;&lt;a href=&quot;/posts/git/&quot;&gt;Git - Read More Posts.&lt;/a&gt;&lt;p&gt;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.&lt;/p&gt;&lt;a href=&quot;mailto:david@davidtsadler.com&quot;&gt;Email david@davidtsadler.com&lt;/a&gt;&lt;h3&gt;License&lt;/h3&gt;&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.&lt;/a&gt;&lt;p&gt;Copyright © 2021 David T. Sadler.&lt;/p&gt;&lt;a href=&quot;/&quot;&gt;Return to Homepage.&lt;/a&gt;</content>
+exit 0&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;This script has been saved as /usr/bin/backup_repositories and is ran daily via cron.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;cron&quot;&gt;0 3 * * * /usr/bin/backup_repositories &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;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&amp;#039;t be suitable for restoring. However its fine for my purposes since I&amp;#039;m the only user and it&amp;#039;s unlikely that I will be making changes during the time the backup is running.&lt;/p&gt;&lt;h3&gt;Links&lt;/h3&gt;&lt;a href=&quot;/posts/git/2021-05-29/setting-up-a-self-host-git-server/&quot;&gt;2021-05-29 - Setting up a Self Hosted Git Server&lt;/a&gt;&lt;a href=&quot;/posts/git/&quot;&gt;Git - Read More Posts.&lt;/a&gt;&lt;p&gt;I don&amp;#039;t have comments as I don&amp;#039;t want to manage them. You can however contact me at the below address if you want to.&lt;/p&gt;&lt;a href=&quot;mailto:david@davidtsadler.com&quot;&gt;Email david@davidtsadler.com&lt;/a&gt;&lt;h3&gt;License&lt;/h3&gt;&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.&lt;/a&gt;&lt;p&gt;Copyright © 2021 David T. Sadler.&lt;/p&gt;&lt;a href=&quot;/&quot;&gt;Return to Homepage.&lt;/a&gt;</content>
</entry><entry>
<title type="text">Setting up a Self Hosted Git Server</title>
<id>https://davidtsadler.com/posts/git/2021-05-29/setting-up-a-self-host-git-server/</id>
@@ -36,7 +36,7 @@ exit 0&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;All it does it tar and gzip any .git dir
<author><name>David T. Sadler.</name></author>
<published>2021-05-29T12:00:00Z</published>
<updated>2021-05-29T12:00:00Z</updated>
- <content type="html">&lt;h1&gt;Setting up a Self Hosted Git Server&lt;/h1&gt;&lt;blockquote&gt;Sat 29th May 2021 By David T. Sadler.&lt;/blockquote&gt;&lt;p&gt;I've always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Installing git.&lt;/li&gt;&lt;li&gt;Creating a git user.&lt;/li&gt;&lt;li&gt;Setting up ssh so that I can log into the sever securely as the git user.&lt;/li&gt;&lt;li&gt;Creating a test repository on the server.&lt;/li&gt;&lt;li&gt;Creating a test project on my local machine.&lt;/li&gt;&lt;li&gt;Pushing the test project to the git sever.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Installing Git&lt;/h2&gt;&lt;p&gt;Since its an Ubuntu server installing git is as simple as.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ sudo apt install git-core&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Creating a User&lt;/h2&gt;&lt;p&gt;The git user will serve two purposes.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The repositories will be stored in the user's home directory.&lt;/li&gt;&lt;li&gt;The user account will contain the public ssh keys of remote users that can access the repositories.&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&lt;li&gt;--system Creates a system user user. Not strictly required but since this is not a normal user account I prefer to use this option.&lt;/li&gt;&lt;li&gt;--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.&lt;/li&gt;&lt;li&gt;--group Creates a group that is the same name as the user.&lt;/li&gt;&lt;li&gt;--disabled-password Prevent logging in with a password. The use of ssh keys is still allowed.&lt;/li&gt;&lt;li&gt;--home /home/git The home directory for the user.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Setting up SSH&lt;/h2&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;The below commands create the required .ssh directory and authorized_keys file with the correct permissions.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ sudo mkdir /home/git/.ssh
+ <content type="html">&lt;h1&gt;Setting up a Self Hosted Git Server&lt;/h1&gt;&lt;blockquote&gt;Sat 29th May 2021 By David T. Sadler.&lt;/blockquote&gt;&lt;p&gt;I&amp;#039;ve always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Installing git.&lt;/li&gt;&lt;li&gt;Creating a git user.&lt;/li&gt;&lt;li&gt;Setting up ssh so that I can log into the sever securely as the git user.&lt;/li&gt;&lt;li&gt;Creating a test repository on the server.&lt;/li&gt;&lt;li&gt;Creating a test project on my local machine.&lt;/li&gt;&lt;li&gt;Pushing the test project to the git sever.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Installing Git&lt;/h2&gt;&lt;p&gt;Since its an Ubuntu server installing git is as simple as.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ sudo apt install git-core&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Creating a User&lt;/h2&gt;&lt;p&gt;The git user will serve two purposes.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The repositories will be stored in the user&amp;#039;s home directory.&lt;/li&gt;&lt;li&gt;The user account will contain the public ssh keys of remote users that can access the repositories.&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&lt;li&gt;--system Creates a system user user. Not strictly required but since this is not a normal user account I prefer to use this option.&lt;/li&gt;&lt;li&gt;--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.&lt;/li&gt;&lt;li&gt;--group Creates a group that is the same name as the user.&lt;/li&gt;&lt;li&gt;--disabled-password Prevent logging in with a password. The use of ssh keys is still allowed.&lt;/li&gt;&lt;li&gt;--home /home/git The home directory for the user.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Setting up SSH&lt;/h2&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;The below commands create the required .ssh directory and authorized_keys file with the correct permissions.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ 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 &amp;#039;Initial commit&amp;#039;
$ git remote add origin git@git.davidtsadler.com:test.git
$ git push origin main&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I can also test that I can clone the repository.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;rm -rf test
-git clone git@git.davidtsadler.com:test.git&lt;/code&gt;&lt;/pre&gt;&lt;h3&gt;Links&lt;/h3&gt;&lt;a href=&quot;/posts/git/&quot;&gt;Git - Read More Posts.&lt;/a&gt;&lt;p&gt;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.&lt;/p&gt;&lt;a href=&quot;mailto:david@davidtsadler.com&quot;&gt;Email david@davidtsadler.com&lt;/a&gt;&lt;h3&gt;License&lt;/h3&gt;&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.&lt;/a&gt;&lt;p&gt;Copyright © 2021 David T. Sadler.&lt;/p&gt;&lt;a href=&quot;/&quot;&gt;Return to Homepage.&lt;/a&gt;</content>
+git clone git@git.davidtsadler.com:test.git&lt;/code&gt;&lt;/pre&gt;&lt;h3&gt;Links&lt;/h3&gt;&lt;a href=&quot;/posts/git/&quot;&gt;Git - Read More Posts.&lt;/a&gt;&lt;p&gt;I don&amp;#039;t have comments as I don&amp;#039;t want to manage them. You can however contact me at the below address if you want to.&lt;/p&gt;&lt;a href=&quot;mailto:david@davidtsadler.com&quot;&gt;Email david@davidtsadler.com&lt;/a&gt;&lt;h3&gt;License&lt;/h3&gt;&lt;a href=&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;&gt;The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.&lt;/a&gt;&lt;p&gt;Copyright © 2021 David T. Sadler.&lt;/p&gt;&lt;a href=&quot;/&quot;&gt;Return to Homepage.&lt;/a&gt;</content>
</entry>
</feed> \ No newline at end of file