Quickly set up GitHub SSH example

One of the most secure ways to communicate across the public internet is to use SSH. This is why GitHub SSH key setup is a top priority for users of the popular Git service.

Fortunately, the GitHub and SSH key configuration process is relatively straightforward, especially on a Linux distribution such as Ubuntu.

GitHub SSH key setup steps

To setup GitHub SSH keys and use them on Ubuntu, follow these steps:

  1. Create a GitHub SSH key pair with the ssh-keygen command
  2. Copy the value of the public SSH key to the clipboard
  3. Login to GitHub and navigate to your account settings
  4. Click on the SSH and GPG link
  5. Click Add Key to register the public SSH key with your account
  6. Name the key and paste the copied  value into the text field
  7. Save your changes
  8. In your Git client, use the SSH based GitHub URL to clone your repo

Let’s go over each of these steps to setup GitHub SSH keys.

Create GitHub SSH keys

In Ubuntu, the SSH keys you create for GitHub must go in the .ssh folder. Perform all the GitHub SSH key create operation in this folder:

github@ubuntu:~$ cd ~/.ssh

Use the ssh-keygen command to create GitHub SSH key pairs:

github@ubuntu:~/.ssh$ ssh-keygen -o -t rsa -C "[email protected]"

The operation will prompt you to choose a location in which to save the public and private keys. Just click return to leave them in the .ssh folder. The SSH command will look here when a connection attempt is made to a remote server.

Git with SSH keys tutorials

Need to configure SSH keys for GitHub, GitLab, BitBucket or CodeDeploy? These Git SSH key examples will help:

Follow these tutorials and you’ll learn to Git over SSH fast.

The ssh-keygen command will also ask you to protect your GitHub SSH key with an optional passphrase. It’s permissible to leave the passphrase blank, so click return when prompted.

Here is the full output of when you issue the ssh-keygen command to create GitHub SSH keys:

github@ubuntu:~/.ssh$ ssh-keygen -o -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Your identification has been saved in /home/ubuntu/.ssh/id_rsa
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub
The key fingerprint is: SHA256:g7RTuw9S+...
The key's randomart image is:
+---[RSA 3072]----+
|  ..Bo+.+o.. |
|. *.= +E . . |
| ...+ .. . . |
| +.. ...+ o  |
|  B o  ++  S |
| o . * = o + |
| o  B.oo  .  |
|   = oo  +   |
|   .o .o .   |

The purpose of the parameters used with the GitHub ssh-keygen command are as follows:

  • The -o flag forces the tool to generate SSH keys with the OpenSSH format
  • The -t flag specifies they type of SSH keys to create
  • The -C flag allows for comments that get added as metadata at the end of the public key

GitHub SSH key location

When the GitHub SSH key create operation completes, the Ubuntu terminal will display a very satisfying piece of randomart.

You will also find public and private GitHub SSH keys in the current directory.

You will need to paste the contents of your public SSH key into GitHub. Cat the file to view its contents in the Ubuntu Terminal and then copy it:

github@ubuntu:~/.ssh$ cat id_rsa.pub

GitHub SSH key config

Next, you must configure the GitHub SSH key in the settings of your online account. Log into GitHub, navigate to your account settings, and find the link named “SSH and GPG keys.” Click on this link to create a new GitHub SSH key. Provide a unique name, and paste the value of the private GitHub SSH key you copied earlier.

setup github ssh key

The window to setup SSH keys in GitHub requires the key value and a generic name.

With the GitHub SSH key setup complete, you can now use the SSH repository GitHub URL to clone from and push to your remote repo.

I will copy the SSH URL of my GitHub repository named rock-paper-scissors and then clone it in Ubuntu.


The SSH based GitHub URL used to clone a repo can be found on a repository’s home page.

SSH Clone of GitHub repo

Once you copy the SSH URL of the GitHub repo, you can use it to clone a copy of the remote repo into the local environment.

On the initial clone, you might get a message that questions the authenticity of the host. This due to the lack of a third party certificate authority to validate your keys. If you are confident in the validity of the keys you just created — which you certainly should be, because you created them — just type yes to carry on with an SSH clone of the GitHub repo.

github@ubuntu:~$ git clone [email protected]:cameronmcnz/rock-paper-scissors.git
Cloning into ‘rock-paper-scissors’…
The authenticity of host ‘github.com (’ can’t be established..
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘github.com,’ (ECDSA) to the list of known hosts.
Resolving deltas: 100% (206/206), done.

Now the GitHub SSH keys are set up properly and you’ve used them to clone the repository. You can continue to issue various Git commands with no worries about the underlying SSH config. All subsequent operations will use the existing setup of SSH keys for GitHub.

And that’s how easy it is to setup GitHub SSH keys in Ubuntu for Git.

App Architecture
Software Quality
  • How to test a predictive model

    Strategies for testing predictive models and analytics emphasize data quality, real-time testing and code redundancy, as well as ...

  • The dos and don'ts of visual testing

    The visual aspect of an application is an important part of UX. Defects can potentially result in lost sales and damaged ...

  • 3 QA testing tools to consider

    QA testers need to be able to put applications and APIs through their paces. Here are some examples of tools that can help with ...

Cloud Computing