Using GitHub via SSH
Table of Contents:
This text will explain connecting to GitHub using SSH protocol.
You can connect and authenticate to remote servers and services using the SSH protocol. With SSH keys, no username or password are needed.
There are always two SSH keys:
- private key and
- public key.
Before you even generate a new SSH keys, check to see if you have any existing SSH keys.
On Windows :
> dir C:\Users\uname\.ssh Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 12/3/2019 11:17 AM 3389 id_rsa -a---- 12/3/2019 11:17 AM 746 id_rsa.pub -a---- 12/5/2019 2:30 PM 1193 known_hosts
id_rsa.pub are typical names for the private and the public keys, although you can rename it to anything you like.
Similar on Linux and Mac from the terminal you can check if you have any keys with this one-liner:
ls -al ~/.ssh
If you already have keys (these
ide_rsa files) add them to the agent:
Adding ssh keys to the
The procedure on Windows:
Ensure first the
ssh-agent is enabled. Check like this:
Status Name DisplayName ------ ---- ----------- Stopped ssh-agent OpenSSH Authentication Agent
If the agent is stopped you need to start it. You can start the
ssh-agent service when you set service Startup type to: Manual.
Status Name DisplayName ------ ---- ----------- Running ssh-agent OpenSSH Authentication Agent
ssh-add C:\Users\uname\.ssh\id_rsa_intel Identity added: C:\Users\dj\.ssh\id_rsa_intel C:\Users\dj\.ssh\id_rsa_intel)
Note the uname represents the actual user name.
If you don’t have SSH keys, you can generate a new SSH key pair.
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Adding a new SSH key to your GitHub account
To configure your GitHub account to use your new (or existing) SSH keyS, you’ll also need to add the public key to your GitHub account.
Go to the your GitHub account settings. You need to be logged in.
Click New SSH key button and add upload the key with the extension
.pub (the public key).
Cloning the repo
From now on, you can open your terminal and clone GitHub repos in SSH style like this:
git clone [email protected]:uname/pname.github.io.git
where uname and pname are username and project name.
…tags: ssh & category: github