大网数据广告活动
服务器运维问答

Permission denied (publickey) - in setting up Kubernetes cluster with Kubespray

· 52CE 我爱测

This issue is from the following documentation How to deploy Kubernetes using Kubespray . I followed their documentation word by word and reached at this point: ansible -i inventory.ini -m ping all Here is the above command in th…

问题原文

原帖链接 · Sebastian · CC BY-SA 4.0

This issue is from the following documentation How to deploy Kubernetes using Kubespray. I followed their documentation word by word and reached at this point:

ansible -i inventory.ini -m ping all

Here is the above command in the documentation

The documentation outlines all the necessary steps on deploying Kubernetes to UpCloud using Kubespray and Terraform. As mentioned earlier, I could execute all the commands until hitting the command: ansible -i inventory.ini -m ping all

Enter passphrase for key '/home/summer/.ssh/id_rsa':
kubespray-worker-2 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '<IP address>' (ECDSA) to the list of known hosts.\r\nubuntu@<IP address>: Permission denied (publickey).",
    "unreachable": true
}

Enter passphrase for key '/home/summer/.ssh/id_rsa':
kubespray-worker-0 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '<IP address>' (ECDSA) to the list of known hosts.\r\nConnection closed by <IP address> port 22",
    "unreachable": true
}

Enter passphrase for key '/home/summer/.ssh/id_rsa':
kubespray-worker-1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '<IP address>' (ECDSA) to the list of known hosts.\r\nubuntu@<IP address>: Permission denied (publickey).",
    "unreachable": true
}
kubespray-master-0 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '<IP address>' (ECDSA) to the list of known hosts.\r\nubuntu@<IP address>: Permission denied (publickey).",
    "unreachable": true
}

the above error in image form for further reference

Please note: The region hidden in white inks are the Public IP addresses assigned to each node in the image above.

I am able to remotely access the Ubuntu server by hitting: ssh <username>@<ip_address>. Here is a snapshot of cluster-settings.tfvars to see if I have messed-up something:

zone     = "fe-fxfx"
username = "ubuntu"

# Prefix to use for all resources to separate them from other resources
prefix = "kubespray"

inventory_file = "inventory.ini"

#  Set the operating system using UUID or exact name
template_name = "Ubuntu Server 20.04 LTS (Focal Fossa)"

ssh_public_keys = [
  # Put your public SSH key here
  "removed the Public Key for security reasons",
]

Also, the image from cluster-settings,tfvars file for reference: cluster-settings.tfvars

The result from pinging the nodes are also irregular, in a sense, if master-0 is successfully pinged at one instance, in the other, none of them gets pinged [when tried again]. While, sometimes worker-2 is pinged and rest are not.

已采纳解答

原帖链接 · Sebastian · CC BY-SA 4.0

I found the answer to this issue after consulting a senior mate. First off, the SSH key pair needs to be generated without a passphrase or if you're using one with a passphrase on, just pass this command to disable it:

Run ssh-keygyen with -p option.

ssh-keygen -p

I suggest you to do this inside the directory where your SSH key-pair is located or specify it with -f ~/<username>/.ssh/id_rsa

If you did the above step correctly, then you'll be prompted to enter the existing passphrase:

Enter old passphrase:

After that, enter the new passphrase [basically leave it blank] and confirm it:

Enter new passphrase (empty for no passphrase):
Enter same passphrase again:

If successful, you will get the following prompt:

Your identification has been saved with the new passphrase.

Note: These steps can be used to remove or change the passphrase.

Next Inside the cluster-settings.tfvars file, there are two places with "enter your SSH key here" option to enter your public keys. It is not mandatory to enter in both. In my case, I used only one of the public keys and also made sure the key pair was available in SSH agent.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-10-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。