Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raises error " knownhosts: key mismatch " when executing “k0sctl apply --disable-telemetry -c k0sctl_deploy.yml ” #445

Closed
ling1042133624 opened this issue Jan 11, 2023 · 1 comment

Comments

@ling1042133624
Copy link

ling1042133624 commented Jan 11, 2023

When i executed "k0sctl apply k0sctl.yml" with k0sctl-v0.15.0, raised errors.

Deployed with version k0sctl-v0.14.0, everything is fine.

output:

(base) root@k0s-node01:~/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy# cd ansible; .k0s_dependencies/k0sctl apply --disable-telemetry -c k0sctl_deploy_tmp/k0sctl_deploy.yml ;cd ..

⠀⣿⣿⡇⠀⠀⢀⣴⣾⣿⠟⠁⢸⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀█████████ █████████ ███
⠀⣿⣿⡇⣠⣶⣿⡿⠋⠀⠀⠀⢸⣿⡇⠀⠀⠀⣠⠀⠀⢀⣠⡆⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀███          ███    ███
⠀⣿⣿⣿⣿⣟⠋⠀⠀⠀⠀⠀⢸⣿⡇⠀⢰⣾⣿⠀⠀⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀███          ███    ███
⠀⣿⣿⡏⠻⣿⣷⣤⡀⠀⠀⠀⠸⠛⠁⠀⠸⠋⠁⠀⠀⣿⣿⡇⠈⠉⠉⠉⠉⠉⠉⠉⠉⢹⣿⣿⠀███          ███    ███
⠀⣿⣿⡇⠀⠀⠙⢿⣿⣦⣀⠀⠀⠀⣠⣶⣶⣶⣶⣶⣶⣿⣿⡇⢰⣶⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⠀█████████    ███    ██████████
k0sctl v0.15.0 Copyright 2022, k0sctl authors.
By continuing to use k0sctl you agree to these terms:
https://k0sproject.io/licenses/eula
INFO ==> Running phase: Connect to hosts 
ERRO [SSH] 192.168.122.144: attempt 1 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO [SSH] 192.168.122.216: attempt 1 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
INFO [ssh] 192.168.122.46:22: connected           
ERRO [SSH] 192.168.122.216: attempt 2 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO [SSH] 192.168.122.144: attempt 2 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO [SSH] 192.168.122.144: attempt 3 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO [SSH] 192.168.122.216: attempt 3 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 

.
.
.

ERRO [SSH] 192.168.122.216: attempt 59 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO [SSH] 192.168.122.216: attempt 60 of 60.. failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO [SSH] 192.168.122.216: failed to connect: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 
ERRO apply failed - log file saved to /root/.cache/k0sctl/k0sctl.log 
FATA failed on 2 hosts:
 - [ssh] 192.168.122.144:22: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch
 - [ssh] 192.168.122.216:22: not connected: client connect: ssh dial: ssh: handshake failed: host key mismatch: knownhosts: key mismatch 

1. os info
Ubuntu 21.04

2. I installed on the new nodes.

3. k0s version
v1.24.8+k0s.0

4. k0sctl yaml config

# k0sctl apply k0sctl.yml
---
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
  name: k0s-cluster
spec:
  k0s:
    version: v1.24.8+k0s.0
    dynamicConfig: false


  hosts:
  - ssh:
      address: 192.168.122.46
      user: root
      port: 22
      keyPath: ~/.ssh/id_ed25519
    role: controller+worker
    privateAddress: 192.168.122.46
    installFlags:
      - --no-taints
      - --disable-components konnectivity-server
    uploadBinary: true
    k0sBinaryPath: "/root/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy/ansible/.k0s_dependencies/k0s"
    files:
      - name: bundle-file
        src: "/root/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy/ansible/.k0s_dependencies/k0s-airgap-bundle"
        dstDir: /var/lib/k0s/images/
        perm: 0666
  - ssh:
      address: 192.168.122.144
      user: root
      port: 22
      keyPath: ~/.ssh/id_ed25519
    role: controller+worker
    privateAddress: 192.168.122.144
    installFlags:
      - --no-taints
      - --disable-components konnectivity-server
    uploadBinary: true
    k0sBinaryPath: "/root/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy/ansible/.k0s_dependencies/k0s"
    files:
      - name: bundle-file
        src: "/root/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy/ansible/.k0s_dependencies/k0s-airgap-bundle"
        dstDir: /var/lib/k0s/images/
        perm: 0666
  - ssh:
      address: 192.168.122.216
      user: root
      port: 22
      keyPath: ~/.ssh/id_ed25519
    role: controller+worker
    privateAddress: 192.168.122.216
    installFlags:
      - --no-taints
      - --disable-components konnectivity-server
    uploadBinary: true
    k0sBinaryPath: "/root/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy/ansible/.k0s_dependencies/k0s"
    files:
      - name: bundle-file
        src: "/root/桌面/k0s/jiege/pulls-65/cloud-service-k0s-deploy/ansible/.k0s_dependencies/k0s-airgap-bundle"
        dstDir: /var/lib/k0s/images/
        perm: 0666


@ling1042133624 ling1042133624 changed the title Raises error " knownhosts: key mismatch " when exec “k0sctl apply --disable-telemetry -c k0sctl_deploy.yml ” Raises error " knownhosts: key mismatch " when executing “k0sctl apply --disable-telemetry -c k0sctl_deploy.yml ” Jan 11, 2023
@kke
Copy link
Contributor

kke commented Jan 11, 2023

This is because you have used the same IP before but have installed the operating system again which changes the host's ssh host key. The same happens if you try to ssh root@192.168.122.144.

Solution 1 - Remove the keys from ~/.ssh/known_hosts file:

$ ssh-keygen -R 192.168.122.144
$ ssh-keygen -R 192.168.122.216

Solution 2 - Configure the address range to not use host key checking:

# ~/.ssh/config
Host 192.168.122.*
  UserKnownHostsFile=/dev/null

Solution 3 - Disable host key checking while running k0sctl:

$ env SSH_KNOWN_HOSTS=/dev/null k0sctl apply -c k0sctl.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants