List

First of all create a GitHub account and a new repository within this account. For the rest of the tutorial I recommend using Git BASH if you are on Windows. This tool can be accessed from this website.

Here we will focus on accessing our repositories through SSH. In order to do so we need a public/private key pair. The tool for this purpose is ssh-keygen and it comes bundled with Git BASH. Launch Git Bash to access the bash command prompt.

Before generating the key create a folder named .ssh under your user folder (e.g. C:\Users\Ongun) in Windows. Note that this folder is already present if you are on Linux/Mac albeit hidden by default.

Then run the following command to generate the SSH public/private key pair.
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"

Default location is okay and you have the option to enter a passphrase. Note that you can change this passphrase later with the following command.

ssh-keygen -p

The remaining step is to put the information in the public key on GitHub website. In order to do so click on your profile icon on the top right in the GitHub (marked green in the following screenshot) and then click SSH and GPG keys (marked red in the following screenshot).

Assuming you go on with the default settings (file name and location) two files are generated under .ssh directory; namely id_rsa (Private),  id_rsa.pub (Public). Don’t forget that you should only put the public key on GitHub not the private key. Assuming you are in the home directory you can print the contents of the public key to screen by issuing the following command in Git BASH:
cat .ssh/id_rsa.pub

Please note that creating the private/public key pair on desktop is just for demonstration purpose.

If you are on Windows before the final step do not forget to set an environmental variable called HOME so that Git looks for the SSH keys in the correct directory. Follow the steps below to set the HOME environmental variable on Windows 10 for the current user.

  1. Right-click on Computer
  2. Choose Properties
  3. Click on Advanced System Settings
  4. Click on Environment Variables
  5. Click on New in the top pane (User Variables)
  6. For Variable name type: HOME
  7. For Variable value type: C:\Users\USERNAME
  8. Click OK

Finally return to the web interface for GitHub click on the green New SSH key button, provide a descriptive title and put the contents of the file into the bottom box. Any text editor can also be used to display the contents of the id_rsa.pub file. After these have been done you should have push/pull access to your public/private repositories.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.