blob: c3d97a30df8f8aaab5049f829ab21e09f0e52fce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
## Using the SSH transport
*SINCE 1.5.0*
The SSH transport is a very exciting improvement to Gitblit. Aside from offering a simple password-less, public key workflow the SSH transport also allows exposes a new approach to interacting with Gitblit: SSH commands. The Gerrit and Android projects have to be thanked for providing great base SSH code that Gitblit has integrated.
### Cloning & Pushing
By default, Gitblit serves the SSH transport on port 29418, which is the same as Gerrit. Why was 29418 chosen? It's likely because it resembles the IANA port assigned to the git protocol (9418).
Gitblit will authenticate using username/password or public keys.
git clone ssh://<username>@<hostname>:29418/myrepository.git
### Setting up your account to use public key authentication
Public key authentication allows you to operate in a password-less workflow and to separate your web login credentials from your git credentials. Setting up public key authentication is very simple. If you are working on Windows you'll need to install [Git for Windows](http://git-scm.com/download/win).
First you'll need to create an SSH key pair, if you don't already have one or if you want to generate a new, separate key.
ssh-keygen
Then you can upload your *public* key right from the command-line.
cat ~/.ssh/id_rsa.pub | ssh -l <username> -p 29418 <hostname> gitblit keys add
cat c:\<userfolder>\.ssh\id_rsa.pub | ssh -l <username> -p 29418 <hostname> gitblit keys add
**NOTE:** It is important to note that *ssh-keygen* generates a public/private keypair (e.g. id_rsa and id_rsa.pub). You want to upload the *public* key, which is denoted by the *.pub* file extension.
Once you've done both of those steps you should be able to execute the following command without a password prompt.
ssh -l <username> -p 29418 <hostname> gitblit version
### Setting up an SSH alias
Typing the following command syntax all the time gets to be rather tedious.
ssh -l <username> -p 29418 <hostname> gitblit version
You can define an alias for your server which will reduce your command syntax to something like this.
ssh <alias> gitblit version
Create or modify your `~/.ssh/config` file and add a host entry. If you are on Windows, you'll want to create or modify `<userfolder>\.ssh\config`, where *userfolder* is dependent on your version of Windows. Most recently this is `c:\users\<userfolder>`.
Host <alias>
IdentityFile ~/.ssh/id_rsa
User <username>
Port 29418
HostName <hostname>
### SSH Commands
Gitblit supports SSH command plugins and provides several commands out-of-the-box.
#### gitblit
The *gitblit* command has many subcommands for interacting with Gitblit.
##### keys add
Add an SSH public key to your account. This command accepts a public key piped to stdin.
cat ~/.ssh/id_rsa.pub | ssh -l <username> -p 29418 <hostname> gitblit keys add
##### keys remove
Remove an SSH public key from your account. This command accepts a public key piped to stdin.
cat ~/.ssh/id_rsa.pub | ssh -l <username> -p 29418 <hostname> gitblit keys remove
You can also remove all your public keys from your account.
ssh -l <username> -p 29418 <hostname> gitblit keys remove ALL
##### keys list
Show the SSH keys you have added to your account.
ssh -l <username> -p 29418 <hostname> gitblit keys list
|