DEV Community

How to Configure ssh keys in your Git-hub Account.

Step 1: Verify Your SSH Key
Check if you have an SSH key: Run:

ls ~/.ssh
Enter fullscreen mode Exit fullscreen mode

Look for files named id_rsaor id_ed25519 and their corresponding .pub files.

  1. If you don't have an SSH key: Generate one using:
 ssh-keygen -t ed25519 -C "your_email@example.com"
Enter fullscreen mode Exit fullscreen mode

Replace your_email@example.com with the email associated with your GitHub account.

  1. Start the SSH agent:
eval "$(ssh-agent -s)"
Enter fullscreen mode Exit fullscreen mode
  1. Add your SSH key to the agent:
ssh-add ~/.ssh/id_ed25513
Enter fullscreen mode Exit fullscreen mode

Step 2: Add the SSH Key to Your GitHub Account.

  1. Copy your public key:
cat ~/.ssh/id_ed25513.pub
Enter fullscreen mode Exit fullscreen mode

Copy the output.

  1. Add it to GitHub:
    • Go to your GitHub SSH keys settings page.
    • Click New SSH key, give it a title, paste the key, and save.

Step 3: Test Your SSH Connection
Run:

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

If successful, you'll see a message like:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Enter fullscreen mode Exit fullscreen mode

Step 4: Clone the Repository Again.
Retry cloning the repository:

git clone git@github.com:username/python-ecomerce-Api.git
Enter fullscreen mode Exit fullscreen mode

Replace username with the GitHub username owning the repository.

If the Issue Persists for not connecting to your account:

  1. Ensure that your SSH key matches the one added to GitHub
 ssh-add -l
Enter fullscreen mode Exit fullscreen mode
  1. Confirm repository access by logging into GitHub and verifying your permissions.

  2. If you're using a corporate network, check for any restrictions or firewall rules blocking SSH connections. Use HTTPS as an alternative:

git clone https://github.com/username/python-ecomerce-Api.git
Enter fullscreen mode Exit fullscreen mode

Top comments (0)