# Cannot SSH to my server from a job, but it's ok in SSH debug

**URL:** <https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083>\
**Category:** Build Environment\
**Tags:** ssh\
**Created:** [February 9, 2021, 9:47am UTC](https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083 "2021-02-09T09:47:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincentEM](https://avatars.discourse-cdn.com/v4/letter/v/a3d4f5/32.png) [@vincentEM](https://discuss.circleci.com/u/vincentEM)\
**Post date:** [February 9, 2021, 9:47am UTC](https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083/1 "2021-02-09T09:47:33Z")

</div>

I’m trying to use cimg/base:stable-20.04 for my deploy jobs. I cannot ssh to my servers from my jobs but I can do it on SSH debug session.

During the job execution:

```
ssh -v vincent@$ip "echo a"
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/circleci/.ssh/config
debug1: /home/circleci/.ssh/config line 2: Applying options for *
debug1: /home/circleci/.ssh/config line 6: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to X.X.X.X [X.X.X.X] port 22.
debug1: connect to address X.X.X.X port 22: Connection refused
ssh: connect to host X.X.X.X port 22: Connection refused
Exited with code exit status 255
CircleCI received exit code 255

```

On an SSH debug session:

```
circleci@324ad8ad87f4:~$ ssh vincent@X.X.X.X
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1037-aws x86_64)

```

If I check /var/log/auth.log on my server, that is running on ubuntu 20.04, I get the following error when the CircleCI job is trying to connect:

```
    Feb 9 09:30:01 ip-XXX sshd[190606]: Connection closed by 3.91.195.239 port 54434 [preauth]
    Feb 9 09:30:01 ip-XXX sshd[190609]: Connection closed by 3.91.195.239 port 54436 [preauth]
    Feb 9 09:30:02 ip-XXX sshd[190607]: Connection closed by 3.91.195.239 port 54438 [preauth]
    Feb 9 09:30:02 ip-XXX sshd[190610]: Unable to negotiate with 3.91.195.239 port 54440: no matching host key type found. Their offer: sk-ecdsa-sha2-nistp256/@openssh.com [preauth]
    Feb 9 09:30:02 ip-XXX sshd[190608]: Unable to negotiate with 3.91.195.239 port 54442: no matching host key type found. Their offer: sk-ssh-ed25519/@openssh.com [preauth]

```

I’m completely certain of the SSH key used since the same job was working with a homemade docker image base on ubuntu 18.04

---

<div class="post-metadata">

**Author:** ![cmdeveloped](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cmdeveloped/32/28362_2.png) [@cmdeveloped](https://discuss.circleci.com/u/cmdeveloped)\
**Post date:** [October 12, 2021, 2:36pm UTC](https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083/2 "2021-10-12T14:36:06Z")

</div>

I’m receiving this same error. Did you ever figure out the solution? @vincentEM

---

<div class="post-metadata">

**Author:** ![vincentEM](https://avatars.discourse-cdn.com/v4/letter/v/a3d4f5/32.png) [@vincentEM](https://discuss.circleci.com/u/vincentEM)\
**Post date:** [October 12, 2021, 3:13pm UTC](https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083/3 "2021-10-12T15:13:46Z")

</div>

Not at all @cmdeveloped sorry. We’re still on ubuntu 18.04 for now…

---

<div class="post-metadata">

**Author:** ![saxelsen](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/saxelsen/32/34039_2.png) [@saxelsen](https://discuss.circleci.com/u/saxelsen)\
**Post date:** [October 26, 2023, 10:21am UTC](https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083/4 "2023-10-26T10:21:30Z")

</div>

I am experiencing this exact error now, using `cimg/base:stable` (as per 2023-10-26).

did you ever figure out a solution to this?

---

<div class="post-metadata">

**Author:** ![saxelsen](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/saxelsen/32/34039_2.png) [@saxelsen](https://discuss.circleci.com/u/saxelsen)\
**Post date:** [October 26, 2023, 12:03pm UTC](https://discuss.circleci.com/t/cannot-ssh-to-my-server-from-a-job-but-its-ok-in-ssh-debug/39083/5 "2023-10-26T12:03:37Z")

</div>

Just wanted to update that it worked for me by downgrading the image to `cimg/base:18.04` . Why, I do not know yet. It didn’t work with `cimg/base:current` (which is a Ubuntu 22.04 image from what I can see) or `cimg/base:20.04`.
