Configure github ssh
Configure GitHub - SSH
Step 1 - Configure GitHub email
Use the following command, making sure to use the email address associated with your
GitHub account.
- git config --global user.email <your@email.com>
Note: If you mistype something, you can run this command again (use the up/down arrow keys in Terminal to cycle through your command history).
Step 2 - Configure Full Name
Use the following command, making sure to use the full name associated with your GitHub
account.
- git config --global user.name 'Your Name'
This is a good time to double check that you've got your name and other information updated in GitHub.
Step 3 - Generate SSH Keys
SSH keys are a way to identify trusted computers without involving passwords. The steps below will walk you through generating an SSH key and then adding the public key to your GitHub account.
In your terminal, connected to your vagrant box, type the following commands:
- cd ~/.ssh
- ls -la
Check the directory listing to see if you have files named either id_rsa.pub or id_dsa.pub. If you don't have either of those files, follow the steps in Configuring a New Key below. Otherwise, skip to Step 4 - Add Your Public Key to GitHub below.
Configuring a New Key
To generate a new SSH key, copy and paste the commands below, making sure to substitute in your email. The default settings are preferred, so when you're asked to "enter a file in which to save the key" just press enter to continue.
Gotcha: The first command (that starts with eval) uses backticks to quote the text that follows, not single quotes.
- eval
ssh-agent -s ssh-keygen -t rsa -C "your_email@example.com"
You should see something like the following: Generating public/private rsa key pair.
Enter file in which to save the key (/home/vagrant/.ssh/id_rsa): [Press enter]
Next, you'll be asked to enter a passphrase. Leave it blank (just hit enter without typing any other characters), as demonstrated below.
Enter passphrase (empty for no passphrase): [Press enter] Enter same passphrase again: [Press enter]
Which should give you something like the following.
Your identification has been saved in /Users/you/.ssh/id_rsa. Your public key has been saved in /Users/you/.ssh/id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
Then, add your new key to the ssh-agent using the following command:
- ssh-add ~/.ssh/id_rsa
Step 4 - Add Your Public Key to GitHub
- From your Vagrant machine, type the following command:
cat ~/.ssh/id_rsa.pub
This will give you a big block of characters which you should highlight and copy from your terminal window.
- In your browser, visit the Account Settings screen on GitHub.
- Click on SSH Keys on the left sidebar.
- Click Add SSH Key.
- In the Title field, add a descriptive label for the new key. For example, since you're using a Vagrant box for Lighthouse, you might call this key "Lighthouse Vagrant Box".
- Paste your key into the "Key" field.
- Click Add key.
- Confirm the action by entering your GitHub password.
Note: It's okay to have multiple SSH keys configured in your GitHub settings. It just means multiple machines have access to pull and push to GitHub using your account credentials.