In order for us to work with GitHub during class, you'll need to authenticate the computer you'll use during class with GitHub. Follow these steps:
Before you generate a new SSH Key
Check to see if you already have an .ssh directory in your home directory. If this is the first time working with SSH keys, you probably don’t a .ssh directory. Note: Directories that start with a dot are usually hidden.
- Open Git Bash (or Terminal if on a Mac)
- Make sure you’re in your home directory.
Type:- cd ~/ (change to your home directory)
Note: The ~ is the last key to the left of the numbers at the top of your keyboard. Press shift + ~ to get the character. - ls -a (to list directories and files including hidden ones)
- cd ~/ (change to your home directory)
- If you have an .ssh directory, change into that directory to see if you already have SSH keys. Type the following two commands
- cd .ssh (switch into the .ssh directory)
- ls (list files in that directory)
- If you have an SSH key in the directory, you can use one of those keys for this class, so you can skip ahead to copying the key to GitHub. Or you can use the instructions below to generate a new key. Just use a different name when you save the key in step 2 and anywhere else where you reference this key. (e.g. id_rsa_gitclass)
Generate a new SSH key
Taken from https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent- Open Git Bash (or Terminal if on Mac). Paste the text below, substituting in your email address. This creates a new ssh key, using the provided email as a label.
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"Response:> Generating public/private rsa key pair.
- When you're prompted to "Enter a file in which to save the key," press Enter.
This accepts the default file location.
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter] - At the prompt, type a secure passphrase, and then write it down so you'll remember it - this passphrase as you will be asked to enter it often.
NOTE: When you type your passphrase, you won't see the characters appear on screen, nor will you see the
cursor move. This is due to security.
- Enter passphrase (empty for no passphrase): [Type a passphrase]
- Enter same passphrase again: [Type passphrase again]
Add your SSH key to the SSH-Agent
Taken from https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
- Ensure the ssh-agent is running. It most likely is. Type:
eval $(ssh-agent -s)Response should look something like:> Agent pid 59566If so, it's running.
- Add your SSH private key to the ssh-agent. Type:
Copy Your SSH Key to add it to GitHub
First, you need a Github account. If you already have one, skip down to item 7.
- Go to http://github.com
- Create an account
- Select the free account unless you want a paid account
- Once you have your Github account set up, go to your account settings, in the upper-right hand corner of the page and choose Settings
- On the left-side menu, choose SSH and GPG keys
- Click the green ‘New SSH Key’ button
- Type a title for your key. It can be anything you want to help identify this key. (Project name, computer name where key lives, etc.)
- Copy the SSH key you created:
- On Windows type: clip < ~/.ssh/id_rsa.pub
- On MacOS type: pbcopy < ~/.ssh/id_rsa.pub
- Paste your SSH Key into the Key section of Github and Save. Your key should end with the email address you entered when you first created your key
Note: when you run this command, nothing will seem to change on your computer. What this command does is copy the text of the key to your clipboard, which will enable you to paste it to GitHub.
You should receive a response: