Ssh

使用 RKE 連接主機失敗

  • June 4, 2019

我有以下 cluster.yml 文件:

nodes:
   - address: 172.16.20.22
     user: rke
     role:
       - controlplane
       - etcd
       - worker

執行時rke up,我收到以下錯誤:

INFO[0000] Building Kubernetes cluster                  
INFO[0000] [dialer] Setup tunnel for host [172.16.20.22] 
WARN[0000] Failed to set up SSH tunneling for host [172.16.20.22]: Can't retrieve Docker Info: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: Unable to access node with address [172.16.20.22:22] using SSH. Please check if you are able to SSH to the node using the specified SSH Private Key and if you have configured the correct SSH username. Error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain 
WARN[0000] Removing host [172.16.20.22] from node lists 
FATA[0000] Cluster must have at least one etcd plane host: failed to connect to the following etcd host(s) [172.16.20.22]

我不確定為什麼 SSH 隧道不起作用,因為我的機器上打開了埠 22。我的機器上還為 http 流量打開了 80 埠,這可以在 firewalld 輸出中看到:

public (active)
 target: default
 icmp-block-inversion: no
 interfaces: ens192
 sources: 
 services: ssh dhcpv6-client http
 ports: 
 protocols: 
 masquerade: no
 forward-ports: 
 source-ports: 
 icmp-blocks: 
 rich rules: 

有誰知道為什麼我的 cluster.yml 配置不能按預期工作?我已經確認我的 rke 使用者和 root 使用者都有通過 SSH 工作的 SSH 密鑰,但我不確定是否需要將它們添加到我的配置文件或它是如何工作的。

您使用的是哪種 SSH 身份驗證?您的 SSH 伺服器似乎只接受 SSH 密鑰。這很好,如果 rke 有一個需要在配置中指定的有效密鑰(全域或基於每個節點):

nodes:
   - address: 172.16.20.22
     user: rke
     ssh_key_path: "/home/rke/.ssh/id_rsa"
     role:
       - controlplane
       - etcd
       - worker

如果密鑰已指定並且僅在您在此處發布的配置中失去,請檢查該密鑰是否有效。使用 SSH 密鑰時需要記住一些事項。最重要的是正確權限(私鑰為 600)。要檢查這一點,只需以與執行 rke 相同的使用者身份連接並嘗試

ssh -i /home/rke/.ssh/id_rsa rke@172.16.20.22

這應該可以工作,否則您將獲得更詳細的錯誤資訊。如果有效,請嘗試執行docker ps. 當使用者不是該docker組的成員時,我遇到了類似的錯誤。在這種情況下,它沒有足夠的權限通過 Docker 套接字進行連接。

引用自:https://serverfault.com/questions/959133