Connecting with the public key

I just downloaded git and am trying to clone my code repository. It keeps getting an error saying that access is denied due to “publickey.” I have checked several times and re-entered it according to what I have. I am new at this, so please give me some information as to what needs to happen to make this work!

I use ssh-add, then my filepath, to add my private key, then try to connect to gitlab. at first it connected, but now it doesn’t even connect, and says there is an error with the public key. either way, either when it 1. failed to connect or 2. connected then failed to clone after connection, there was an error with the public key. I used chatgpt 4o to troubleshoot. It told me to enter the command “ssh-add -1” into the terminal to see if the key was added correctly, but every time I use it, an error pops up: ssh-add: unknown option – 1
usage: ssh-add [-CcDdKkLlqvXx] [-E fingerprint_hash] [-H hostkey_file]
[-h destination_constraint] [-S provider] [-t life]
[file …]
ssh-add -s pkcs11 [-Cv] [certificate …]
ssh-add -e pkcs11
ssh-add -T pubkey …

That is all I get. After that, ChatGPT doesn’t quite know how to solve it. Any help would be appreciated. Thanks!!!

:hugs: Please help fill in this template with all the details to help others help you more efficiently. Use formatting blocks for code, config, logs and ensure to remove sensitive data.

Problem to solve

Describe your question in as much detail as possible:

  • What are you seeing, and how does that differ from what you expect to see?
  • Consider including screenshots, error messages, and/or other helpful visuals

Steps to reproduce

Which troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

Configuration

Provide screenshots from the GitLab UI showing relevant configuration, if applicable.
On self-managed instances, add the relevant configuration settings or changes.

Versions

Please select whether options apply, and add the version information.

Versions

Helpful resources

  1. Before opening a new topic, make sure to search for keywords in the forum search
  2. Check the GitLab project for existing issues. If you encounter a bug, please create a bug report issue.
  3. Troubleshooting docs: Self-managed GitLab instances.

Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hi,

I’d suggest you to follow documentation on creating an SSH Key pair: Use SSH keys to communicate with GitLab | GitLab from scratch.

At the end of the process, you should have two files in your user’s SSH folder (C:\Users\youruser\.ssh on Windows or ~\.ssh on Linux):

  • private key (e.g. id_rsa if you used RSA algorithm)
  • public key (e.g. id_rsa.pub)

You copy the content of id_rsa.pub (you can open it with any text editor) and paste it in GitLab (Your Profile > SSH > New SSH Key).

Then you should be able to clone.

1 Like