How to Clone a GitHub Repository Using SSH on a Linux Machine?

Hey, I stumbled upon you guys while checking out some other forums. Still haven’t cracked the answer I need. I’m kinda new to this whole coding thing, so I’d really be grateful if you could give me a hand with this techy problem. All I wanna do is get into GitHub using SSH and clone a repo on my Linux machine.

1 Like

Hey there! No worries :slight_smile: , we’ve got this. Let’s dive in and get your Linux machine set up to clone that GitHub repo using SSH. It’s easier than it sounds, promise!

Step 1: Generate SSH Key

Generate a new SSH key using the ED25519 algorithm, associating it with your email. Replace your-email@example.com with your actual email address:

ssh-keygen -t ed25519 -C "your-email@example.com"

Step 2: Install xclip

Install xclip to enable copying of the SSH key to the clipboard:

sudo apt-get install xclip

Step 3: Copy SSH Key to Clipboard

Use xclip to copy the public SSH key to your clipboard. This command reads the public key and pipes it into xclip:

xclip -sel clip < ~/.ssh/id_ed25519.pub

Step 4: Add SSH Key to Git Repository

Go to your Git repository settings and add the copied SSH key as a deploy key.

To ensure the SSH key has been copied correctly, you can output the contents of the clipboard:

xclip -o -sel clip

Step 5: Clone the Repository

Finally, you can clone the repository using SSH on your Linux machine:

git clone git@github.com:username/example.git
2 Likes

Wow, that worked like a charm! Thanks a ton for breaking it down so simply and clearly. Really appreciate the help! :hugs: