# Added my SSH key, cannot push to Spaces repo

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%3E%5C
**Category:** Spaces\
**Created:** [December 16, 2024, 12:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631 "2024-12-16T00:55:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![trusktr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/trusktr/32/37636_2.png) [@trusktr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrusktr)%5C
**Post date:** [December 16, 2024, 12:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F1 "2024-12-16T00:55:21Z")

</div>

Hello, this is my first time using HuggingFace (I’ve been using GitHub for a long time), and I’m super excited to push code repos with live examples!

I added my SSH key in settings, but it will not let me push to my new Spaces repo.

Here’s my new account: [trusktr (Joe Pea)](https://huggingface.co/trusktr)

I can verify that SSH works, like so:

```auto
$ ssh git@hf.co
PTY allocation request failed on channel 0
Hi anonymous, welcome to Hugging Face.
Connection to hf.co closed.

```

(It says “anonymous”, does that indicate an problem inside HF?)

I created my first Space here:

> **[Lume - a Hugging Face Space by lume-creative](https://huggingface.co/spaces/lume-creative/lume)**
>
> GPU-powered 3D HTML. ✨🧊 \<lume-box size="1 2 3"\>

When I try to push to this repo, I get this:

```auto
$ git remote -v
hf git@hf.co:spaces/lume-creative/lume (fetch)
hf git@hf.co:spaces/lume-creative/lume (push)

$ git push hf develop
remote: 
remote: ========================================================================
remote: 
remote: ERROR: This action requires authentication.
Make sure your SSH public key is linked with your profile on huggingface.co.
See https://huggingface.co/settings/keys.

remote: 
remote: ========================================================================
remote: 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

```

It seems like there’s a bug in HF, because the `ssh` test works (but tells me I am anonymous), so the key is accepted, but I am not recognized as the owner of my SSH key.

I’ve logged in with `huggingface-cli` but no luck. Here’s `huggingface-cli env`:

```auto
$ huggingface-cli env
/Users/trusktr/Library/Python/3.9/lib/python/site-packages/urllib3/ __init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.26.5
- Platform: macOS-15.0.1-arm64-arm-64bit
- Python version: 3.9.6
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: /Users/trusktr/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: trusktr
- Configured git credential helpers: osxkeychain
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- keras: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: N/A
- pydantic: N/A
- aiohttp: N/A
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /Users/trusktr/.cache/huggingface/hub
- HF_ASSETS_CACHE: /Users/trusktr/.cache/huggingface/assets
- HF_TOKEN_PATH: /Users/trusktr/.cache/huggingface/token
- HF_STORED_TOKENS_PATH: /Users/trusktr/.cache/huggingface/stored_tokens
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10

```

After logging in with `huggingface-cli`, I get the same error as above when I `git push`. But I think that makes sense, as `git` is simply using SSH.

---

<div class="post-metadata">

**Author:** ![trusktr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/trusktr/32/37636_2.png) [@trusktr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrusktr)%5C
**Post date:** [December 16, 2024, 1:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F2 "2024-12-16T01:47:59Z")

</div>

Looks like someone else has the exact same issue here, with no answer:

> [@Issue with SSH keys - always anon](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fissue-with-ssh-keys-always-anon%2F88959)%3A
>
> Hi there, I hope that everyone is doing well. I’m wondering if anybody else has run into this? I’ve been trying to setup my ssh keys so that I can clone spaces etc. directly via ssh and not have to input my token everytime I want to push via HTTP. I’ve generated the appropriate keys, and have added the .pub file contents to my account under the SSH keys section. This all seems to go well. When I try to run ssh -T git@hf.co I still get the output Hi anonymous, welcome to Hugging Face. if …

---

<div class="post-metadata">

**Author:** ![trusktr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/trusktr/32/37636_2.png) [@trusktr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrusktr)%5C
**Post date:** [December 16, 2024, 2:29am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F3 "2024-12-16T02:29:24Z")

</div>

Similar issue:

> [@Can't Push to New Space](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-push-to-new-space%2F35319)%3A
>
> I’m getting the following errors when trying to push to my new space for the first time. remote: ------------------------------------------------------------------------- remote: You are not authorized to push to this repo. remote: Make sure that you are properly logged in. remote: ------------------------------------------------------------------------- To https://huggingface.co/spaces/Grokgpt/grokgpt ! [remote rejected] main -\> main (pre-receive hook declined) error: failed to push some refs …

---

<div class="post-metadata">

**Author:** ![trusktr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/trusktr/32/37636_2.png) [@trusktr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrusktr)%5C
**Post date:** [December 16, 2024, 3:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F4 "2024-12-16T03:02:03Z")

</div>

I tried erasing macOS ssh credential as described here:

> [@Can't Push to New Space](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-push-to-new-space%2F35319%2F24)%3A
>
> Ok. I managed to git push to the space. There seems to be some issue with osxkeychain. I ran the following commands to erase the existing token/password in osxkeychain: git credential-osxkeychain erase ⏎ host=huggingface.co ⏎ protocol=https⏎ ⏎ ⏎ Where ⏎ is Enter

But no luck.

---

<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:** [December 16, 2024, 3:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F5 "2024-12-16T03:08:18Z")

</div>

@not-lain ssh issue.

---

<div class="post-metadata">

**Author:** ![trusktr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/trusktr/32/37636_2.png) [@trusktr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrusktr)%5C
**Post date:** [December 16, 2024, 3:14am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F6 "2024-12-16T03:14:05Z")

</div>

I managed to get git to connect by using the HTTPS remote URL format with `user:token`.

```config
[remote "hf"]
	url = https://trusktr:<TOKEN>@huggingface.co/spaces/lume-creative/lume
	fetch = +refs/heads/*:refs/remotes/hf/*

```

However, now when I try to push, it fails:

```txt
❯ git push --recurse-submodules=no hf develop
Enumerating objects: 18207, done.
Counting objects: 100% (18207/18207), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5958/5958), done.
error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (18207/18207), 72.05 MiB | 154.67 MiB/s, done.
Total 18207 (delta 13630), reused 16295 (delta 11969), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date

```

The errors:

```auto
error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly

```

Have I goofed something up with LFS? Or is it something else like the git submodules which I have not yet pushed to HF?

EDIT: running this,

```sh
git config --global http.postBuffer 157286400

```

fixed the previous error by increasing memory size (or something). Looks like its an error related to the HTTP connection, which I haven’t encountered before as I always use SSH.

Now I’m receiving new errors like

```auto
... omitted ...
remote: Resolving deltas: 100% (13632/13632), done.
remote: -------------------------------------------------------------------------
remote: Your push was rejected because it contains files larger than 10 MiB.
remote: Please use https://git-lfs.github.com/ to store large files.
remote: See also: https://hf.co/docs/hub/repositories-getting-started#terminal
remote: 
remote: Offending files:
remote: - docs/examples/velodyne-lidar-scan/shelby-scene.ply (ref: refs/heads/main)
remote: - docs/examples/velodyne-lidar-scan/shelby-scene.ply (ref: refs/tags/v0.3.0-alpha.10)
remote: - docs/examples/velodyne-lidar-scan/shelby-scene.ply (ref: refs/tags/v0.3.0-alpha.11)
... omitted ...

```

so now I’ll try LFS.

EDIT: after installing Git LFS, my `git push`es still get rejected. I’ll open a separate thread for that:

---

<div class="post-metadata">

**Author:** ![matthewfranglen](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@matthewfranglen](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmatthewfranglen)%5C
**Post date:** [February 18, 2025, 6:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F7 "2025-02-18T18:57:39Z")

</div>

I had the same problem. I had to use ssh-add to add the key to my keychain. After that git push worked.

---

<div class="post-metadata">

**Author:** ![trusktr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/trusktr/32/37636_2.png) [@trusktr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftrusktr)%5C
**Post date:** [February 18, 2025, 9:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F8 "2025-02-18T21:25:44Z")

</div>

In my case I fixed it by changing the encryption method from `ed25519` to `ecdsa` (or the other way around, can’t remember). One of them works, the other doesn’t.

(Both of them work with GitHub)

---

<div class="post-metadata">

**Author:** ![gsavelev](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/gsavelev/32/41973_2.png) [@gsavelev](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fgsavelev)%5C
**Post date:** [February 25, 2025, 6:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F9 "2025-02-25T18:33:45Z")

</div>

Let SSH agent know which key to use when you want to communicate with [hf.co](http://hf.co)  
You could do so in SSH config file (on macOS it’s _.ssh/config_) by

```auto
Host hf.co
User hf_username
IdentityFile path_to_your_private_key
IdentitiesOnly yes
AddKeysToAgent yes

```

---

<div class="post-metadata">

**Author:** ![daqc](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/daqc/32/41969_2.png) [@daqc](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdaqc)%5C
**Post date:** [March 1, 2025, 2:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F10 "2025-03-01T02:16:22Z")

</div>

In my case, since I’m working on Cursor, I switched from Microsoft’s SSH Remote extension to [this one](https://open-vsx.org/extension/jeanp413/open-remote-ssh).  
No connection errors and Git works fine. Btw, I’m using ED25519

---

<div class="post-metadata">

**Author:** ![quanghuynt14](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/quanghuynt14/32/56705_2.png) [@quanghuynt14](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fquanghuynt14)%5C
**Post date:** [March 29, 2026, 6:36am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fadded-my-ssh-key-cannot-push-to-spaces-repo%2F131631%2F11 "2026-03-29T06:36:26Z")

</div>

Hey! This solution works for me. Should we fix this or add it to the documentation here: [Git over SSH · Hugging Face](https://huggingface.co/docs/hub/security-git-ssh#testing-your-ssh-authentication)
