# Huggingface says ssh-keygen Key is invalid

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%3E%5C
**Category:** Beginners\
**Created:** [November 18, 2024, 1:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466 "2024-11-18T01:51:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![viyer9](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@viyer9](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fviyer9)%5C
**Post date:** [November 18, 2024, 1:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F1 "2024-11-18T01:51:27Z")

</div>

I have tried to add a public key formatted like so:

[sk-ssh-ed25519@openssh.com](mailto:sk-ssh-ed25519@openssh.com) \<SSH\_PUBLIC\_KEY\> username@Names-MacBook-Air.local

It immediately results in a 400 error saying the key is invalid

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [November 18, 2024, 2:17am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F2 "2024-11-18T02:17:15Z")

</div>

I don’t think there’s anything wrong with the procedure, but it seems that errors may occur depending on the environment.

> **[How to fix huggingface ssh authentication error with git](https://dev.to/darkmavis1980/how-to-fix-huggingface-ssh-authentication-error-with-git-1l6m)**
>
> So I recently started to use huggingface.co to store and retrieve models for our AI project at work,...

---

<div class="post-metadata">

**Author:** ![viyer9](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@viyer9](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fviyer9)%5C
**Post date:** [November 18, 2024, 3:43am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F3 "2024-11-18T03:43:36Z")

</div>

Thanks for replying. That person seems to have gotten past the stage of adding it to [the account settings](https://huggingface.co/settings/keys). I haven’t been able to add the public key in that settings page. It redirects me to a 400 error page which says “Invalid SSH Key”.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [November 18, 2024, 3:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F4 "2024-11-18T03:51:44Z")

</div>

In the case of a 403 error, account-based restrictions are often suspected, but in the case of a 400 error, what could it be?  
The authentication-related functions of HF often have bugs, so I think that some setting is probably wrong somewhere that we don’t know about…

> [@Unable to clone repository via ssh](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Funable-to-clone-repository-via-ssh%2F79478)%3A
>
> I followed [Git over SSH](https://huggingface.co/docs/hub/security-git-ssh#generating-a-new-ssh-keypair) to test my SSH authentication (base) ➜ ssh -T git@hf.co Hi ivnle, welcome to Hugging Face. ivnle is the correct account that I added my public key to, but I’m unable to clone this repository. (base) ➜ git clone hf.co:datasets/bigcode/starcoderdata data/starcoderdata-raw Cloning into 'data/starcoderdata-raw'... ivanlee@hf.co: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the reposi…

---

<div class="post-metadata">

**Author:** ![viyer9](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@viyer9](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fviyer9)%5C
**Post date:** [November 18, 2024, 9:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F5 "2024-11-18T09:54:23Z")

</div>

It says the SSH key I inputted is invalid. Given that the same method of generation worked for github/gitlab, I’m suspecting hf has a bug of some sort here in validating public keys.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [November 18, 2024, 9:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F6 "2024-11-18T09:55:56Z")

</div>

@not-lain It might be a nasty bug.

---

<div class="post-metadata">

**Author:** ![not-lain](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/not-lain/32/59092_2.png) [@not-lain](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnot-lain)%5C
**Post date:** [November 18, 2024, 1:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F7 "2024-11-18T13:12:10Z")

</div>

Hi @viyer9  
Can you run the command `ssh -T git@hf.co` and let me know what you see ?

alternatively can you try the steps mentioned in

> **[Git over SSH](https://huggingface.co/docs/hub/security-git-ssh#testing-your-ssh-authentication)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

and let me know how it goes ?  
make sure that you add your public ssh key to your huggingface account settings as mentioned in the docs, this can be done by going to [Hugging Face – The AI community building the future.](https://huggingface.co/settings/keys) and pasting your public key in the ssh key section.

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/a/f/af6c1527213446a22d91ad2b9f8bdbacaeb6fce8.png)

---

<div class="post-metadata">

**Author:** ![viyer9](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@viyer9](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fviyer9)%5C
**Post date:** [November 18, 2024, 9:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F8 "2024-11-18T21:34:53Z")

</div>

The part which involves adding the key in my account settings is where I run into the 400 error. When I hit the “Add Key” button it immediately redirects me to a 400 error page saying “SSH Key Invalid” and does not add the key to my account settings.

---

<div class="post-metadata">

**Author:** ![not-lain](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/not-lain/32/59092_2.png) [@not-lain](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnot-lain)%5C
**Post date:** [November 18, 2024, 11:21pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F9 "2024-11-18T23:21:18Z")

</div>

@viyer9  
that’s ideed weird, try opening a private window login and do not use any adblockers, vpn or any extra security measures and let me know how this goes

---

<div class="post-metadata">

**Author:** ![viyer9](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@viyer9](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fviyer9)%5C
**Post date:** [November 19, 2024, 12:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F10 "2024-11-19T00:01:44Z")

</div>

I tried a new chrome install with incognito mode with (no VPN or adblock used). It still redirects to the 400 page saying “Invalid SSH Key”. I also tried with/without a newline at the end of the key comment.

---

<div class="post-metadata">

**Author:** ![not-lain](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/not-lain/32/59092_2.png) [@not-lain](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnot-lain)%5C
**Post date:** [November 19, 2024, 12:36am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F11 "2024-11-19T00:36:40Z")

</div>

cc @pierric if you want to take a look

---

<div class="post-metadata">

**Author:** ![pierric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierric/32/50750_2.png) [@pierric](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpierric)%5C
**Post date:** [November 20, 2024, 8:36pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhuggingface-says-ssh-keygen-key-is-invalid%2F125466%2F12 "2024-11-20T20:36:51Z")

</div>

Sorry about that @viyer9 - after further investigation it turns out we do not support the following formats for SSH keys:

- `sk-ecdsa-sha2-nistp256@openssh.com`
- `sk-ssh-ed25519@openssh.com`

Some of our documentation is stating differently, we’ll update it ASAP.
