|
| 1 | +# Accessing GitHub with Key |
| 2 | + |
| 3 | +### Procedure |
| 4 | + |
| 5 | +0. We want to sync our command line (where we run git) with GitHub. The goal is to get our code into the **mycode** repo we created. Move to the **~/.ssh** home directory. |
| 6 | + |
| 7 | + `student@bchd:~$` `cd /home/student/.ssh` |
| 8 | + |
| 9 | +0. Now we will generate a new RSA keypair. We will use this to communicate securely with GitHub because as of August 2021, GitHub will no longer accept passwords from us. This will generate two files, the private key (**id_rsa_github**) and the public key (**id_rsa_github.pub**). |
| 10 | + |
| 11 | + `student@bchd:~/.ssh$` `ssh-keygen -f id_rsa_github` |
| 12 | + |
| 13 | + ``` |
| 14 | + Generating public/private rsa key pair. |
| 15 | + Enter passphrase (empty for no passphrase): |
| 16 | + ``` |
| 17 | +
|
| 18 | + > When you see this, you will need to hit enter twice |
| 19 | +
|
| 20 | + ``` |
| 21 | + Enter same passphrase again: |
| 22 | + Your identification has been saved in id_rsa_github. |
| 23 | + Your public key has been saved in id_rsa_github.pub. |
| 24 | + The key fingerprint is: |
| 25 | + SHA256:DFjw7WCP+u2luMtPATqKHGBi/+XNUzlRYfqIYz8S2/Q student@bchd |
| 26 | + The key's randomart image is: |
| 27 | + +---[RSA 2048]----+ |
| 28 | + | ... +. | |
| 29 | + | + . + | |
| 30 | + |oo . * . o | |
| 31 | + |= . o O . = | |
| 32 | + | . .o ..S= * . | |
| 33 | + |.....oo +.O o | |
| 34 | + |... .. ..*.+ E | |
| 35 | + | o + oo . | |
| 36 | + | *== | |
| 37 | + +----[SHA256]-----+ |
| 38 | + ``` |
| 39 | +
|
| 40 | +0. Next we need to copy the text from inside of the **id_rsa_github.pub** public key into our clipboard. We will need to paste this into GitHub soon. |
| 41 | +
|
| 42 | + `student@bchd:~/.ssh$` `cat id_rsa_github.pub` |
| 43 | +
|
| 44 | + ``` |
| 45 | + ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvTemj7NIlxXEu97VyN4wcmob+F0wQ0nPinZSdUvlWSGAx790EmfXmckZ01/aFDOKIA4OZWYtW95DaGqQ+Tja3QUYlAdTdIlp4TTgH3ZE+KdaLc16rN9FzHv8hwdLFx8CugNw/u/sDbYjEM1qlazB5fbAf0LZ+mN5iCDn6IaYbPZ0wQdF9s4RI/z5wS5wE/J++KV/xJA0f2ICZwaKj4Kq/fron2KoYRkCYcma0oHYvVSnnuxCVGbOJdhWK1LiJRPweNUajp0OItECJxgCR1gB/DVEWnBmknOcPnY6q3QeaUrm28nPSAjGTkfFSHDbOJptaqKaSkRhwNsuOGiw6KQ1R student@bchd |
| 46 | + ``` |
| 47 | +
|
| 48 | + > Select all of the output and copy it. NOTE: Yours will be different than the one listed above! |
| 49 | +
|
| 50 | + **RETURN TO GITHUB NOW** |
| 51 | +
|
| 52 | +0. At the top of the screen, click on your username to return to your homepage. |
| 53 | +
|
| 54 | +0. You should see your repository `mycode-dev`. Click into it. |
| 55 | +
|
| 56 | +0. Near the top right of the screen, there is a little gear icon that says **Settings**. Click on that. |
| 57 | +
|
| 58 | +0. On the left of the screen, click on **Deploy Keys**. Deploy keys are essentially a token that we set up that allow somebody to read from, and optionally write to, our repository, even if it is private. They just need to have the private key set up on their system as a means of authenticating with the public key stored on github. |
| 59 | +
|
| 60 | +0. Your screen should look like the following. Click on the button that says **Add deploy key**. |
| 61 | +
|
| 62 | +  |
| 63 | +
|
| 64 | +0. Give your key a name. **alta3 environment** would work. Then paste your key (from **id_rsa_github.pub**) into the large text box. And also click on the checkbox that says **Allow write access**. Then, click **Add key**. |
| 65 | +
|
| 66 | +  |
| 67 | +
|
| 68 | +## Other Useful Resources |
| 69 | +
|
| 70 | +- If you ever run into a problem using git / GitHub, let the instructor know. It is critical to start learning to version control code. You might want to spend some time clicking around on the following guides. They're quite short, and although you might not understand what they're talking about, they'll begin exposing you to the way we 'speak' when using git & version controlling software. Some getting started guides relating to GitHub can be found here: <a href="https://guides.github.com/" target="_blank">https://guides.github.com/</a> |
| 71 | +
|
| 72 | +- Windows and Mac users might also check out the local client GitHub Desktop, available at <a href="https://desktop.github.com/" target="_blank">https://desktop.github.com/</a> This client makes it **easy** to work through git via a local GUI on your Windows or Mac desktop environment. |
| 73 | +
|
| 74 | +<br><br><div align="center"> |
| 75 | +
|
| 76 | + |
| 77 | +
|
| 78 | +</div> |
0 commit comments