Copy-Paste SSH registration list
I keep this To create an SSH key and register it with GitHub, follow these steps:
Step 1: Check for Existing SSH Keys
Before creating a new SSH key, check if you already have one:
- Open a terminal (Linux/Mac) or Git Bash (Windows).
- Run the following command to check for existing SSH keys:
ls -al ~/.ssh
Look for files like
id_rsa
andid_rsa.pub
orid_ed25519
andid_ed25519.pub
. If they exist, you can use them or create a new one.
Step 2: Generate a New SSH Key
If you don’t have an SSH key or want to create a new one:
- Run the following command (replace
your_email@example.com
with your GitHub email):ssh-keygen -t ed25519 -C "your_email@example.com"
- If your system doesn’t support
ed25519
, use:ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- If your system doesn’t support
-
When prompted to “Enter a file in which to save the key,” press
Enter
to accept the default location. - Optionally, set a passphrase for added security. You can press
Enter
to skip this step.
Step 3: Add the SSH Key to the SSH Agent
- Start the SSH agent:
eval "$(ssh-agent -s)"
- Add your SSH private key to the agent:
ssh-add ~/.ssh/id_ed25519
(If you used
rsa
, replaceid_ed25519
withid_rsa
.)
Step 4: Copy the SSH Public Key
- Copy the contents of your public key to the clipboard:
cat ~/.ssh/id_ed25519.pub
(Or
id_rsa.pub
if you used RSA.) - Highlight the output and copy it.
Step 5: Add the SSH Key to GitHub
- Go to GitHub and log in to your account.
- Click on your profile picture in the top-right corner and select Settings.
- In the left sidebar, click SSH and GPG keys.
- Click the New SSH key button.
- Give the key a title (e.g., “My Laptop”).
- Paste the copied public key into the “Key” field.
- Click Add SSH key.
Step 6: Test the SSH Connection
- Run the following command to test the connection:
ssh -T git@github.com
- If successful, you’ll see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Step 7: Use SSH with GitHub
Now you can use SSH to interact with GitHub repositories. For example:
- Clone a repository using SSH:
git clone git@github.com:username/repository.git
- Set the remote URL of an existing repository to use SSH:
git remote set-url origin git@github.com:username/repository.git
That’s it! You’ve successfully created an SSH key and registered it with GitHub. 🎉