Issue with new SSH Known Hosts feature – host registered but still not found

Hi everyone,

I’ve been testing the new SSH Known Hosts feature, but I’m running into some issues.

Even though I’ve registered my known host according to the documentation, Okteto keeps returning errors saying that the host is not found. I’ve double-checked that the hostname and key are correctly added, but the issue persists.

Additionally, when I try to use ssh-keyscan (as suggested in the docs) to retrieve the host key, it doesn’t seem to work correctly inside my Okteto environment — it either times out or returns an empty response.

Has anyone else experienced this behavior?

Is there something I might be missing in the configuration or in how Okteto validates known hosts?

Any help or clarification from the Okteto team would be greatly appreciated.

Thanks in advance!

Some logs:
ssh-keyscan failed after 8 attempts: failed to retrieve the SSH keys from "gitlab.ourdomain.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.ourdomain.com": exit status 1error in FinishPipeline: Post "https://okteto.dev.ourdomain.com/graphql": read tcp 10.255.222.9:57900->172.20.237.72:443: read: connection reset by peer

Hey @marticardus , based on the error messages, it doesn’t seem like the error is related to KNOWN_HOSTS but instead to network access between Okteto and Gitlab.

Can you verify that Okteto is able to resolve the DNS and reach out to your Gitlab instance. Other users in the past have had to explicitly open the HTTPS and/or SSH ports on their firewall and gitlab configurations for this to work.

Hi @ramiro ,

I found this on some pods: (buildkit, registry, installer)

/ # cat /etc/hosts
172.20.237.72 okteto.dev.ourdomain. com
172.20.237.72 registry.dev.ourdomain. com

This causes the error (error in FinishPipeline: Post “https:// oktetodev.ourdomain com/graphql”: read tcp 10.255.222.9:57900->172.20.237.72:443: read: connection reset by peer), because is it the internal address of the ingress-nginx service with proxy protocol enabled, if I remove these entries, the service responds correctly.

But I think this were another problem that i need to resolve, maybe in another thread?

The current problem, as I understand it, is that despite having the “Known hosts” configured, it is doing a scan, when it should directly clone the repository.

Kind regards

For the known_hosts issue, can you check on Admin > Known Hosts if the feature is enabled?

Yes, it is

Could you share here the full log of the deployment ? Please remove any sensitive information.

Sure, here is the full log:

Successfully assigned okteto/installer-c8f3fca8-af41-4464-b843-a164bcb15ac4-4hq57 to ip-10-255-199-115.eu-west-3.compute.internalCreated pod: installer-c8f3fca8-af41-4464-b843-a164bcb15ac4-4hq57Container image "okteto/okteto:3.12.0" already present on machineCreated container: setupStarted container setupContainer image "okteto/pipeline-runner:1.37.1" already present on machineCreated container: installerStarted container installerDeploying Dev Environmentinitialized kubernetes client with InClusterConfigssh-keyscan operation failed (attempt 1/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 1s (attempt 2/8)ssh-keyscan operation failed (attempt 2/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 2s (attempt 3/8)ssh-keyscan operation failed (attempt 3/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 4s (attempt 4/8)ssh-keyscan operation failed (attempt 4/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 8s (attempt 5/8)ssh-keyscan operation failed (attempt 5/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 16s (attempt 6/8)ssh-keyscan operation failed (attempt 6/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 32s (attempt 7/8)ssh-keyscan operation failed (attempt 7/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 1m4s (attempt 8/8)Retrying ssh-keyscan operation in 32s (attempt 7/8)ssh-keyscan operation failed (attempt 7/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 1m4s (attempt 8/8)ssh-keyscan operation failed after 8 attemptsssh-keyscan failed after 8 attempts: failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1error in FinishPipeline: Post "https://okteto.dev.<domain>.com/graphql": read tcp 10.255.222.2:53222->172.20.237.72:443: read: connection reset by peerDeploying Dev Environmentinitialized kubernetes client with InClusterConfigssh-keyscan operation failed (attempt 1/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 1s (attempt 2/8)ssh-keyscan operation failed (attempt 2/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 2s (attempt 3/8)ssh-keyscan operation failed (attempt 3/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 4s (attempt 4/8)ssh-keyscan operation failed (attempt 4/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 8s (attempt 5/8)ssh-keyscan operation failed (attempt 5/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 16s (attempt 6/8)ssh-keyscan operation failed (attempt 6/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 32s (attempt 7/8)ssh-keyscan operation failed (attempt 7/8): failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1Retrying ssh-keyscan operation in 1m4s (attempt 8/8)ssh-keyscan operation failed after 8 attemptsssh-keyscan failed after 8 attempts: failed to retrieve the SSH keys from "gitlab.<domain>.com", please review that the hostname is correct, and that your network configuration permits traffic between Okteto and "gitlab.<domain>.com": exit status 1error in FinishPipeline: Post "https://okteto.dev.<domain>.com/graphql": read tcp 10.255.222.9:40228->172.20.237.72:443: read: connection reset by peer

Thanks, I’m following up internally to see if this is a bug or known issue. To help us speed out the resolution, could you share your support bundle?

Also, is there anything unique about your gitlab instance that can help us diagnose this? (e.g. features disabled, custom configurations, etc…).

And what cloud provider/Kubernetes provider/Kubernetes version are you hosting Okteto on?

Hi @ramiro ,

Here is our support bundle https://drive.google.com/file/d/1GABWm0ZRKVSwG01ekdNICAV2icV1YySF/view?usp=drive_link

Our GitLab and Okteto installations are hosted in the same cluster of Kubernetes with EKS version 1.32.

To enable SSH in GitLab, I’ve configured Load Balancer with proxy protocol. All services working on same LB with ingress-nginx

Hey,

The team confirmed that this is a bug, they are already working on a fix. We will update this thread when the fix is ready for you to consume it.

Thanks for your patience with this!

Hi Martí,
We’ve identified an issue in the known hosts implementation where the ssh-keyscan command was being executed during deployment even when the known hosts file was already enabled, this shouldn’t have happened. The unnecessary execution of ssh-keyscan caused the deployment to fail. This behavior has been fixed and available in chart release 1.37.2.

In your case, the ssh-keyscan failure appears to be caused by a connection issue. Since ssh-keyscan will no longer run in the new version, any connection problems might now appear during the repository clone step instead. Although the fix prevents the ssh-keyscan issue, the underlying connectivity problem might still affect the cloning process.

After upgrading to the new release, please:

  1. Check if the connection problem persists.
  2. Verify your network configuration, particularly:
    • That the target host is reachable from the deployment environment.
    • DNS resolution for the Git server works as expected.
    • Firewall or proxy rules are not blocking outbound SSH traffic.
    • The correct SSH port (usually 22) is open and accessible.

Let us know if the issue continues after upgrading, we’ll be happy to help troubleshoot further.

Hi,

I believe the issue is caused by our GitLab instance being behind a Load Balancer with the Proxy Protocol enabled (for SSH connections).

This bug seems to be fixed in the latest update, but I think the underlying cause of the problem is still present.

Deploying Dev Environment
initialized kubernetes client with InClusterConfig
checkout command: ‘[git clone --depth 1 ssh://git@gitlab.ourdomain.com/repo.git -b pre /okteto/src]’
Cloning git repository ‘ssh://git@gitlab.ourdomain.com/repo.git’ branch ‘pre’…Cloning into ‘/okteto/src’…
Running okteto pipeline at:

  • Commit: 83c7558852e2e6e257abef581e080fac43d9d78b
  • Message: add missing cache tokens fields
    okteto information:
  • okteto cli version: v3.12.0
    executing ‘okteto context’…
    x Internal server error, please try again
    exit status 1
    error in FinishPipeline: Post “https:// okteto.dev.ourdomain .com/graphql”: read tcp 10.255.222.10:35642->172.20.237.72:443: read: connection reset by peer

As you can see, it’s trying to connect to the internal ingress service, but it fails because it expects a Proxy-type connection, while only a standard HTTP request is being sent — that’s why the connection doesn’t work.

Kind regards

This issue has been resolved.

The SSH Known Hosts bug has been fixed in Okteto, and the connectivity problem was solved by configuring the official Okteto ingresses as ClusterIP services behind my main ingress controller.

Everything is now working as expected. Thanks to the Okteto team for the quick fix!

1 Like