Skip to content

Instantly share code, notes, and snippets.

@jaygiang
Last active September 24, 2018 23:09
Show Gist options
  • Save jaygiang/59bd5392e36fee7932ca996a0fa1ab1b to your computer and use it in GitHub Desktop.
Save jaygiang/59bd5392e36fee7932ca996a0fa1ab1b to your computer and use it in GitHub Desktop.
Setting Up SSH account for multiple students

Generating SSH Keys

  1. Open Terminal
  2. Paste the text below, substituting in your GitHub email address.
ssh-keygen -t rsa -b 4096 -C "student_emaill@example.com"
  1. 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
  1. 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 **

Adding your SSH key to ssh-agent

  1. Start the ssh-agent in the background.
eval "$(ssh-agent -s)"
  1. Add SSH keys to ssh-agent
  • On Mac
ssh-add -K ~/.ssh/id_rsa
  • On Windows
ssh-add ~/.ssh/id_rsa

Add 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

Create a Git Config File

  1. Open git config file with Nano(easier to use) or Vim
nano ~/.ssh/config 

If no config file, create config file

touch ~/.ssh/config
  1. 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
  1. Save config file
  • If in Nano, hit ctrl + x then type y to save
  • If in Vim, hit ctrl + ;, then type wq to save
  1. To test, clone a repo, git add, git commit, then git push to see if it works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment