- Open Terminal
- Paste the text below, substituting in your GitHub email address.
ssh-keygen -t rsa -b 4096 -C "student_emaill@example.com"
- When you're prompted to "Enter a file in which to save the key," start with prefix
id_rsa
then students name.
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): id_rsa_STUDENTNAME
- At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
** YOUR PASSPHRASE WILL BE HIDDEN WHILE TYPING **
- Start the ssh-agent in the background.
eval "$(ssh-agent -s)"
- Add SSH keys to ssh-agent
- On Mac
ssh-add -K ~/.ssh/id_rsa
- On Windows
ssh-add ~/.ssh/id_rsa
- Follow the steps below https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
Note When running pbcopy < ~/.ssh/id_rsa_STUDENTNAME.pub
, please make sure you are copying the correct student public key
- Open git config file with Nano(easier to use) or Vim
nano ~/.ssh/config
If no config file, create config file
touch ~/.ssh/config
- The git config file should look like this
Host me.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_STUDENNAME1
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_STUDENTNAME2
- Save config file
- If in Nano, hit
ctrl + x
then typey
to save - If in Vim, hit
ctrl + ;
, then typewq
to save
- To test, clone a repo, git add, git commit, then git push to see if it works