You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup_transport_ssh.mkd 4.8KB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ## Using the SSH transport
  2. *SINCE 1.5.0*
  3. 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.
  4. You may watch an Asciinema screencast of using the SSH transport and it's command infrastructure [here](https://asciinema.org/a/9342).
  5. ### Cloning & Pushing
  6. 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).
  7. Gitblit will authenticate using username/password or public keys.
  8. git clone ssh://<username>@<hostname>:29418/myrepository.git
  9. ### Setting up your account to use public key authentication
  10. 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).
  11. 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.
  12. ssh-keygen
  13. **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.
  14. #### Uploading your public key from the command-line
  15. Then you can upload your *public* key right from the command-line.
  16. cat ~/.ssh/id_rsa.pub | ssh -l <username> -p 29418 <hostname> keys add
  17. cat c:\<userfolder>\.ssh\id_rsa.pub | ssh -l <username> -p 29418 <hostname> keys add
  18. #### Uploading your public key through the browser
  19. 1. Navigate to your *profile* page from the dropdown user menu.
  20. 2. Click the *SSH Keys* tab and paste your public key into the *Add SSH Key* form.
  21. 3. Click the *Save* button
  22. Once you ave uploaded your public key you should be able to execute the following command without a password prompt.
  23. ssh -l <username> -p 29418 <hostname>
  24. ### Setting up an SSH alias
  25. Typing the following command syntax all the time gets to be rather tedious.
  26. ssh -l <username> -p 29418 <hostname>
  27. You can define an alias for your server which will reduce your command syntax to something like this.
  28. ssh <alias>
  29. 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>`.
  30. Host <alias>
  31. IdentityFile ~/.ssh/id_rsa
  32. User <username>
  33. Port 29418
  34. HostName <hostname>
  35. ### SSH Commands
  36. Gitblit supports SSH command plugins and provides several commands out-of-the-box.
  37. #### keys
  38. The *keys* command dispatcher allows you to manage your public ssh keys. You can list keys, add keys, remove keys, and identify the key in-use for the active session.
  39. ##### keys add
  40. Add an SSH public key to your account. This command accepts a public key piped to stdin.
  41. cat ~/.ssh/id_rsa.pub | ssh -l <username> -p 29418 <hostname> keys add
  42. ##### keys list
  43. Show the SSH public keys you have added to your account.
  44. ssh -l <username> -p 29418 <hostname> keys list
  45. ##### keys remove
  46. Remove an SSH public key from your account. This command accepts several input values, the most useful one is an index number which matches the index number displayed in the `list` command.
  47. ssh -l <username> -p 29418 <hostname> keys remove 2
  48. You can also remove all your public keys from your account.
  49. ssh -l <username> -p 29418 <hostname> keys remove ALL
  50. ##### keys permission
  51. You may control the access permission for each SSH key. This is more of a safety feature than a security measure.
  52. | Permission | Description |
  53. | ---------- | ----------------------------------------------- |
  54. | V | SSH key may not be used for clone/fetch or push |
  55. | R | SSH key may be used to clone/fetch |
  56. | RW | SSH key may be used to clone/fetch and push |
  57. ### Mac OSX Fonts
  58. Many of Gitblit's SSH commands rely on ANSI border characters to provide a pretty presentation of data. Unfortunately, the fonts provided by Apple - while very nice - don't work well with ANSI border characters. The following public domain fixed-width, fixed-point, bitmapped fonts work very nicely. I find the 6x12 font with a line spacing of ~0.8 to be quite acceptable.
  59. [6x12.dfont](6x12.dfont)
  60. [6x13.dfont](6x13.dfont)
  61. [7x13.dfont](7x13.dfont)
  62. [7x14.dfont](7x14.dfont)