Setting Up Your SSH Configuration File To Work With GitHub
When I first started coding, I didn’t know anything about ssh configuration files. So when I would commit my code to GitHub, I first started out by cloning repositories using an HTTPS based remote.
This meant I had to enter my GitHub username and password every time I wanted to push and pull. Needless to say, the more code I wrote, the more tedious this became.
So I began looking for a faster way and found the ssh configuration file.
What is an SSH Configuration file?
The SSH configuration file lets your system automatically read options from the config file automatically.
So instead of having to type out something like the below,
ssh firstname.lastname@example.org -p 2200
you can type something like ssh bruce.
It’s much faster than HTTPS.
Step 1: Set up SSH Configuration
If you’re on a Mac OSX or Linux system, you can simply type:
This creates an empty config file if it doesn’t already exist.
Step 2: Enter the options in your SSH configuration file
Step 3: Generate Public and Private keys
ssh-keygen -f example_github_key -C "example_github_key"
Step 4: Set up GitHub With Your Private and Public Keys
The below screenshot shows where you add your public key output by the cat command.
Now, when you do a push/pull with GitHub, you’ll only have to enter the password credential you made in Step 3.
Creating an SSH configuration file to work with GitHub is easy.
- Setup the SSH configuration file
- Enter the options in the SSH configuration file
- Generate public and private keys
- Enter your public key in GitHub