# Permission denied (publickey) when trying to ssh to container

**URL:** <https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294>\
**Category:** Bug Reports\
**Tags:** ssh\
**Created:** [March 18, 2022, 2:24pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294 "2022-03-18T14:24:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jandudulski](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jandudulski/32/18060_2.png) [@jandudulski](https://discuss.circleci.com/u/jandudulski)\
**Post date:** [March 18, 2022, 2:24pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/1 "2022-03-18T14:24:46Z")

</div>

Hi,

suddenly circleci containers start refusing my ssh connections. I believe it start happening after I updated the GPG key but I have no clue how this could be connected.

I repeated all the steps from [Debugging with SSH - CircleCI](https://circleci.com/docs/2.0/ssh-access-jobs/#debugging-permission-denied-publickey) and everything seems to be fine:

```auto
$ ssh git@github.com
PTY allocation request failed on channel 0
Hi jandudulski! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

```

The used for authentication to github is also offered while connecting to circle:

```auto
debug1: Offering public key: /home/jandudulski/.ssh/id_rsa RSA SHA256:XfGPsB5pqXKbzic4XlbioYCRCc/AMuBuMNZQmNMn50w agent
debug1: send_pubkey_test: no mutual signature algorithm

```

What else I can try?

---

<div class="post-metadata">

**Author:** ![jerdog](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jerdog/32/32130_2.png) [@jerdog](https://discuss.circleci.com/u/jerdog)\
**Post date:** [March 22, 2022, 11:51pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/2 "2022-03-22T23:51:19Z")

</div>

If you re-added a GPG key, you might have to Unfollow the project on the UI and then Follow again in order to verify auth

---

<div class="post-metadata">

**Author:** ![jandudulski](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jandudulski/32/18060_2.png) [@jandudulski](https://discuss.circleci.com/u/jandudulski)\
**Post date:** [March 23, 2022, 9:55am UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/3 "2022-03-23T09:55:35Z")

</div>

GPG key is used only for signing commits, not for SSH auth. And I already tried to unfollow, sing out and remove OAuth token - nothing helped.

---

<div class="post-metadata">

**Author:** ![brandonw](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/brandonw/32/29763_2.png) [@brandonw](https://discuss.circleci.com/u/brandonw)\
**Post date:** [March 28, 2022, 7:14pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/4 "2022-03-28T19:14:07Z")

</div>

I am seeing identical behavior except I have not changed a gpg key. Is it possible circleci changed something regarding minimum key length or algo? I have a 2048 bit length SHA256-RSA key that has worked in the past. It still authenticates to GitHub without issue. It is only sshing to circleci jobs that give me the error:

```auto
debug1: send_pubkey_test: no mutual signature algorithm

```

A newly generated 4096 bit length SHA256/RSA key still did not work.

A newly generated SHA256/ED25519 key did work.

---

<div class="post-metadata">

**Author:** ![djm204](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/djm204/32/28577_2.png) [@djm204](https://discuss.circleci.com/u/djm204)\
**Post date:** [April 5, 2022, 7:38pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/5 "2022-04-05T19:38:22Z")

</div>

+1 on this issue, myself and some coworkers experiencing this seemingly out of no where.

Have confirmed that SSH keys work for github following debug steps linked above. Everything “seems fine” alas nothing.

Even tried adding new keys and everything,.

---

<div class="post-metadata">

**Author:** ![owenjoliver](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/owenjoliver/32/28293_2.png) [@owenjoliver](https://discuss.circleci.com/u/owenjoliver)\
**Post date:** [April 7, 2022, 12:34pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/6 "2022-04-07T12:34:08Z")

</div>

Hello

I suspect the situation you’re facing is related to changes Github implemented with regards to SSH keys

> **[Improving Git protocol security on GitHub | The GitHub Blog](https://github.blog/2021-09-01-improving-git-protocol-security-github/)**
>
> We’re changing which keys are supported in SSH and removing unencrypted Git protocol. If you’re an SSH user, read on for the details and timeline.

Depending on the key type, signature algorithms, or algorithms, and also, depending on when the key was created you might see different outcomes.

Let me know if the above information helps.

---

<div class="post-metadata">

**Author:** ![m4olivei](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/m4olivei/32/30048_2.png) [@m4olivei](https://discuss.circleci.com/u/m4olivei)\
**Post date:** [May 3, 2022, 5:45pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/7 "2022-05-03T17:45:38Z")

</div>

I ran into this today after updating to Pop OS 22.04. More relevant I _think_ is that my OpenSSH version was also updated (8.9).

I was seeing the same issue as @brandonw eg.

```auto
debug1: send_pubkey_test: no mutual signature algorithm

```

I followed the CircleCI debugging post as well as read through the Github blog post.

@brandonw 's fix worked for me, eg. generate a new SHA256/ED25519 key (`ssh-keygen -t ed25519`) and upload that key to my Github account.

A co-worker of mine pointed out that there were some breaking changes as of OpenSSH 8.8 that may affect signatures used. From [https://www.openssh.com/txt/release-8.8:](https://www.openssh.com/txt/release-8.8:)

> This release disables RSA signatures using the SHA-1 hash algorithm  
> by default. This change has been made as the SHA-1 hash algorithm is  
> cryptographically broken, and it is possible to create chosen-prefix  
> hash collisions for \<USD$50K [1]

> Incompatibility is more likely when connecting to older SSH  
> implementations that have not been upgraded or have not closely tracked  
> improvements in the SSH protocol. For these cases, it may be necessary  
> to selectively re-enable RSA/SHA1 to allow connection and/or user  
> authentication via the HostkeyAlgorithms and PubkeyAcceptedAlgorithms  
> options.

Indeed if I add the suggested changes to `~/.ssh/config`, I can get past the error above with my old keys:

```auto
Host old-host
        HostkeyAlgorithms +ssh-rsa
	PubkeyAcceptedAlgorithms +ssh-rsa

```

This would imply that CircleCI is using an old SSH agent and needs to update for compatibility with newer client agents. Or CircleCI needs to inform users to update to a SHA256/ED25519 key.

---

<div class="post-metadata">

**Author:** ![tom0](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tom0/32/30916_2.png) [@tom0](https://discuss.circleci.com/u/tom0)\
**Post date:** [August 24, 2022, 2:18pm UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/8 "2022-08-24T14:18:38Z")

</div>

I am running into the same issue as everyone else, and seeing the “no mutual signature algorithm” error as posted above.

@m4olivei 's solution of creating a `.ssh/config` file resolved the issue for me.

---

<div class="post-metadata">

**Author:** ![dmgarland](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dmgarland/32/31590_2.png) [@dmgarland](https://discuss.circleci.com/u/dmgarland)\
**Post date:** [November 14, 2022, 10:30am UTC](https://discuss.circleci.com/t/permission-denied-publickey-when-trying-to-ssh-to-container/43294/9 "2022-11-14T10:30:02Z")

</div>

I needed to do this after an upgrade to Ventura on Mac OSX. SSH config solution works if I put the host name for the SSH session as the `Host` directive
