fixup links again, due to redirect taking over!
[gitolite-doc.git] / docs / basic-admin.mkd
blob539cc902018aaafea1ed64263306527154cdc6b1
1 # basic administration
3 ----
5 <span class="green box-r">If you really, really, really want to manage
6 gitolite directly on the server, i.e., without cloning the gitolite-admin
7 repo, you can -- [here's how][ssa].  This is likely to be of interest mainly
8 to puppet/chef type installations.</span>
10 [ssa]: odds-and-ends/#administering-gitolite-directly-on-the-server
12 Day-to-day management of a gitolite site is done by cloning the special
13 'gitolite-admin' repo, making appropriate changes to it, and pushing it back
14 to the server.  The [concepts and terminology](concepts) page has a section
15 with some details on what happens after the push.
17 <span class="red">In other words, do **NOT** add new repos or users manually on the
18 server!</span>
20 # clone the gitolite-admin repo
22 To clone the admin repo, go to the workstation where the public key used in
23 'setup' came from, and run this:
25     git clone git@host:gitolite-admin
27 NOTE that (1) you must not include the `repositories/` part (gitolite handles
28 that internally), and (2) you may include the ".git" at the end but it is
29 optional.
31 If this step fails, be sure to look at the two pages linked from the [[ssh]]
32 page before asking for help.  A very basic first step is to run the `info`
33 command (`ssh git@host info`); [this][info] page tells you what to expect.
35 [info]: user/#the-info-command
37 # add/remove users
39 <span class="gray">NOTE: This section only applies to ssh mode.  If you've installed
40 gitolite in http mode, adding and removing users is outside the scope of
41 gitolite.</span>
43 Strictly speaking, gitolite doesn't know where users come from.  (If that
44 surprises you, go back to the [[concepts]] page and read the section on
45 "authentication and authorisation"). However, gitolite does help with
46 ssh-based authentication, by making it easy to add and remove users from
47 `~/.ssh/authorized_keys`.
49 To add or remove users, you have to clone the gitolite-admin repository, then
50 add or remove ssh pubkey files from the "keydir/" directory in the clone.
51 Then commit those changes and push.
53 Here's how to add users to gitolite.  "alice" is the administrator and is
54 adding "bob" and "carol".
56 ![](ba01.png)
58 All this is done from the admin (Alice)'s workstation.  The steps are:
60 1.  Run `git clone git@server:gitolite-admin`.
62 2.  Obtain pubkeys from each user; email, USB, DHL, pigeon post, owl mail, any
63     method you like.
65     Rename each received file to the name of the user, add a ".pub" at the
66     end, copy it into `keydir/` in the gitolite-admin repo you cloned.
68 3.  Run `git add keydir`, then `git commit`, then `git push`.
70 You do NOT need to add Carol or Bob as *real* (Unix) users.  You do NOT add
71 their keys directly anywhere on the server, and you most definitely do NOT
72 fiddle with the authorized\_keys file on the server directly!
74 To **remove** a user, `git rm keydir/alice.pub`.
76 Commit and push the changes.  On receiving the push, gitolite will carry out
77 the changes specified.
79 **NOTE**: your users' public key is typically
80 `$HOME/.ssh/id_rsa.pub` on her workstation.  Please make sure it is in
81 openssh's default format.
83 ## multiple keys per user
85 You can put pubkeys in subdirectories within "keydir/", because the user name
86 is simply the *base name* of the public key file name.  That is,
87 'keydir/alice.pub', 'keydir/home/alice.pub', 'keydir/laptop/alice.pub', (or
88 even 'keydir/work/desktop/alice.pub' -- any number of subdirectory levels are
89 OK) all resolve to user "alice".
91 This is the simplest and most understandable way to allow multiple keys per
92 user.
94 Please see appendix 2 at the bottom of this document for an older way that
95 will continue to be supported but has proved hard to explain!
97 # add, remove, and rename repos
99 [existing]: basic-admin/#appendix-1-bringing-existing-repos-into-gitolite
101 !!! warning ""
103     Note: this page describes how to add **new** repos.  To bring already
104     existing repos under gitolite's control, click [here][existing].
106 To **add** a new repo, you have to clone the gitolite-admin repository, then
107 edit the [`conf/gitolite.conf`](conf) file. In that file, add the repo, along
108 with at least one user with some permissions.
110 You can add the new repo in its own paragraph,
112 ```gitolite
113 repo bar
114     RW+     =   alice
117 or you can add it to an existing repo line, if the new repo is intended to
118 have the same access rules:
120 ```gitolite
121 repo foo bar
122     RW+     =   alice
125 Either way, commit and push the changes.  Gitolite will create a bare, empty,
126 repo on the server that is ready to be cloned and pushed to.
128 ----
130 As you can see, the "repo" line can have any number of repo names or repo
131 group names in it. However, it can only be one line; this will not work:
133 ```gitolite
134 repo foo
135 repo bar    # WRONG; 'foo' is now forgotten
136     RW+     =   alice
139 If you have too many to fit on one line comfortably, you can create and use a
140 [repo group][groups]:
142 [groups]: conf/#group-definitions
144 ```gitolite
145 @myrepos    =   foo
146 @myrepos    =   bar
147     .
148     .
149     .
150 @myrepos    =   zzq
152 repo @myrepos
153     RW+     =   alice
156 ## removing/renaming a repo
158 Removing a repo is not so straightforward.  You certainly must remove the
159 appropriate lines from the `conf/gitolite.conf` file, but gitolite will not
160 automatically delete the repo from the server.  You have to log on to the
161 server and do the dirty deed yourself :-)
163 It is best to make the change in the conf file, push it, and *then* go to the
164 server and do what you need to.
166 Renaming a repo is also not automatic.  Here's what you do (and the order is
167 important):
169   * Go to the server and rename the repo at the Unix command line.  Don't
170     forget to retain the ".git" extension on the directory name.
171   * Change the name in the conf/gitolite.conf file in your gitolite-admin repo
172     clone, and add/commit/push.
174 # appendix 1: bringing existing repos into gitolite
176 !!! danger "Warning!"
178     Gitolite **will clobber** any existing `update` hook in your repos when
179     you do this.  Please see either the [[cookbook]] or the [[non-core]] page
180     for information on how to make your existing update hook work with
181     gitolite.
183     Gitolite *may clobber* any existing "git-daemon-export-ok" file in your
184     repo; see the page on [allowing access to gitweb and
185     git-daemon](gitweb-daemon) for how to enable that via gitolite.
187 With that out of the way, here's how to do this:
189 First, on the server:
191   * Move the repos to `$HOME/repositories`.
193   * Make sure that:
195       * They are all *bare* repos.
196       * All the repo names end in ".git".
197       * All the files and directories are owned and writable by the gitolite
198         [hosting user][hu] (especially true if you copied them as root).
199       * There are no symbolic links left over from wherever the files were
200         brought from.
202   * Run `gitolite setup`.  **If you forget this step, you can also forget
203     about write access control!**
205 [hu]: concepts/#the-hosting-user
207 Then, back on your workstation:
209   * If the repos are normal repos, add them to the `conf/gitolite.conf` in
210     your clone of the admin repo, then commit and push the change.
212     If the repos are [wildcard](wild) repos that already match some repo regex
213     in the conf file, you need to manually create the gl-creator file, like
214     so:
216         echo username > ~/repositories/path/to/repo.git/gl-creator
218     I haven't yet found this to be common enough to bother wrapping it in a
219     nice interface or command.
221 # appendix 2: old style multi-keys
223 There is another way that involves creating key files like `alice@home.pub`
224 and `alice@laptop.pub`, but there is a complication because gitolite also
225 allows *full email addresses* as user names.  (i.e., `sitaramc@gmail.com.pub`
226 denotes the user called `sitaramc@gmail.com`).
228 This older method of enabling multi-keys was developed to deal with that.  It
229 will continue to work and be supported in *code*, simply because I prefer it.
230 But I will not accept questions or doc patches for it, because it seems it is
231 too difficult to understand for a lot of people.  This table of sample pubkey
232 filenames and the corresponding derived usernames is all you get:
234   * plain username, no multikey
236         sitaramc.pub                            sitaramc
238   * plain username, with multikeys
240         sitaramc@laptop.pub                     sitaramc
241         sitaramc@desktop.pub                    sitaramc
243   * email address as username, no multikey
245         sitaramc@gmail.com.pub                  sitaramc@gmail.com
247   * email address as username, with multikeys
249         sitaramc@gmail.com@laptop.pub           sitaramc@gmail.com
250         sitaramc@gmail.com@desktop.pub          sitaramc@gmail.com