> ## Content Index
> Fetch the complete content index at: https://www.techloy.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to set an SSH connection to GitHub from Ubuntu
- URL: https://www.techloy.com/how-to-set-an-ssh-connection-to-github-from-ubuntu/
- Published: 2025-06-12T13:40:55.000Z
- Updated: 2025-06-12T13:40:55.000Z
- Description: Master SSH key management on Ubuntu, secure multiple GitHub accounts, projects, and servers with ease.
- Author: Oyinebiladou Omemu
- Tags: / Tech Guide, Ubuntu Linux, GitHub

If you’re tired of typing your [GitHub](https://www.techloy.com/tag/github/) password every time you push code or just want a more secure way to interact with your repositories, SSH keys are the answer. Unlike HTTPS, which requires constant authentication, SSH establishes a secure, password-less connection between your [Ubuntu](https://www.techloy.com/tag/ubuntu-linux/) machine and GitHub, making your workflow faster and safer. 

In this guide, learn how to generate an SSH key, add it to GitHub, and use SSH with GitHub actions. By the end, you’ll be able to clone, push, and pull repositories without ever entering a password again.

[How to Install Node.js on Ubuntu Using the Package ManagerGet Node.js and npm installed on Ubuntu quickly using the built-in package manager with this easy guide.![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/icon/techloy-avatar-1-2285.png)TechloyOyinebiladou Omemu![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/thumbnail/photo-1592609931095-54a2168ae893-1)](https://www.techloy.com/how-to-install-node-js-on-ubuntu-using-the-package-manager/)

## How to Set Up SSH Connection to GitHub from Ubuntu

### Step 1: Check for Existing SSH Keys 

Before generating a new key, check if you already have one:

`ls ~/.ssh`

If you see files like "id\_rsa" and "id\_rsa.pub", you already have a key pair, so just skip to Step 4\. 

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-116-1.png)

### Step 2: Generate a new SSH Key

Run this command (replace the email with your GitHub email): 

`ssh-keygen -t rsa -b 4096 -C "youremail@example.com"`

The command above saves your SSH with the default name. To customize the name of your SSH key, enter :

`ssh-keygen -t rsa -b 4096 -C "youremail@gmail.com" -f ~/.ssh/id_rsa_custom-name`

You'll be asked to enter a passphrase. You can hit the Enter key if you don't want to have to enter a passphrase whenever you need to use SSH, but it is recommended to add a passphrase for extra security. 

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-117-1.png)

### Step 3: Copy Your Public Key

Display and copy your public key: 

`cat ~/.ssh/id_rsa.pub`

Select and copy the entire output (starts with ssh and ends with your email). If you set up your key to use a custom name like I did, don't forget to add the ".pub" to the end of the name. The ".pub" tells it to return the public key, which GitHub needs.

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-120-1-1.png)

### Step 4: Add the SSH Key to GitHub

- Go to your GitHub Settings and click on SSH and GPG Keys on the left panel.
- Click New SSH Key.

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-119-1.png)

- Give it a title and paste your public key. Then click "Add SSH Key".

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-121-1.png)

### Step 5: Test the Connection

Verify everything works: 

`ssh -T git@github.com`

You should see: "Hi (username), You’ve successfully authenticated, but GitHub does not provide shell access."

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-122-1.png)

### Step 7: Clone a Repository (Optional)

Now that you have connected to GitHub, you can clone repos using SSH URLs instead of HTTPS: 

`git clone [SSH URL]`

![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/2025/06/image-123.png)

[How to Upgrade Your Ubuntu ReleaseThis guide will show you the entire process, from preparing your system to handling post-upgrade cleanup.![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/icon/techloy-avatar-1-2287.png)TechloyOyinebiladou Omemu![](https://storage.ghost.io/c/c1/a6/c1a6d111-d951-41ad-a392-c1e841210b93/content/images/thumbnail/photo-1629654291663-b91ad427698f-6)](https://www.techloy.com/how-to-upgrade-your-ubuntu-release/)

### Conclusion

That’s it. You’ve now set up a secure SSH connection between your Ubuntu machine and GitHub. Now you can easily perform GitHub actions like cloning, pulling, etc., with ease. There will be no more password prompts, just smooth, encrypted Git operations.

Keep your keys secure, because that is your access to your account, and you won't want it to get out of your hands. To be safe, always use a passphrase for your SSH keys. 

*Image Credit: Oyinebiladou Omemu/Techloy.com*