/workbook/markdown/03-SSH_Setup.md

http://github.com/matthewmccullough/git-workshop · Markdown · 40 lines · 25 code · 15 blank · 0 comment · 0 complexity · 465236f452694e68f3061d4485348e51 MD5 · raw file

  1. # SSH Setup
  2. ## Setting up an SSH Key
  3. This next step works with msysGit (Git for Windows) or on any *NIX system.
  4. ssh-keygen -t rsa -C "yourname@yourcompany.com"
  5. The `-t` flag is the algorithms used to create the key. The `-C` flag is the comment attached to the key. The comment can serve as a reminder of which system you use this with if you are going to generate more than one key pair to partition your Git SSH key from other SSH-authenticated systems and servers.
  6. Other algorithms, like DSA, can also be used for SSH authentication and are compatible with Git, since Git is merely using the operating system's underlying SSH capabilities.
  7. ssh-keygen -t dsa -C "yourname@yourcompany.com"
  8. Lengthier instructions for SSH key generation can be found at the [excellent GitHub page](http://help.github.com/msysgit-key-setup/).
  9. The decision whether or not to use a passphrase for your SSH keys can [also be found on GitHub](http://help.github.com/working-with-key-passphrases/).
  10. ## Sharing the Public portion of the Key
  11. Most Git services use half of the key we just generated for authenticating instead of the typical username and password. In security terms, SSH keys are quite a bit stronger than usernames.
  12. Keep the private half of the key (`id_rsa`) protected. Give away the public half (`id_rsa.pub`) liberally. You could even store it in a directory service if desired.
  13. ## Authorizing the key on another server
  14. If you are in control of a server on which you'll be storing Git repos, you can authorize your account to automatically sign in. While logged in to the remote server, put the contents of a user's `id_rsa.pub` file on a single line (*absolutely no linebreaks!*) on a file named `~/.ssh/authorized_keys`.
  15. Similarly, key strings are copied-and-pasted to web based repositories like GitHub via the user interface. Copy the contents of `id_rsa.pub` to the clipboard and paste it into the appropriate textbox in the web UI of GitHub.
  16. ## Testing SSH
  17. If you wish to test if you have passwordless (key authentication) working correctly, just SSH to the server. It will use your `id_rsa` and `id_rsa.pub` files automatically if they live in `~/.ssh/`. You should not see any prompt for a password.
  18. ssh SERVERNAME
  19. In the case of a gitolite server, it will report your repository permissions before terminating.
  20. hello mccm06, the gitolite version here is v1.5.5-68-g3cf2970
  21. the gitolite config gives you the following access:
  22. R W gitolite-admin
  23. @R @W testing
  24. @R W testinglessaccess
  25. Connection to mybigserver closed.