安裝後步驟
您可以在安裝完成後執行以下程序來增強 Harvester 叢集的安全性和效能。
停用 SSH 密碼
在安裝期間,Harvester 節點預設啟用 SSH 密碼驗證。這允許管理員存取節點以進行安裝診斷。
然而,一旦安裝完成,建議停用 SSH 密碼驗證。您可以執行以下命令,使用 kubectl 套用 CloudInit 配置,以在所有 Harvester 節點上停用 SSH 密碼驗證:
cat <<EOF | kubectl apply -f -
apiVersion: node.harvesterhci.io/v1beta1
kind: CloudInit
metadata:
name: ssh-config
spec:
matchSelector:
harvesterhci.io/managed: "true" # 套用到所有 Harvester 節點
filename: 99-ssh-config
contents: |
stages:
network:
- name: "disable password login"
commands:
- sed -i -E 's/^#?PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
- sed -i -E 's/^#?ChallengeResponseAuthentication .*/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
- sed -i -E 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config
- systemctl restart sshd
paused: false
EOF
備註
matchSelector欄位用於選擇具有特定標籤的 Harvester 節點。- 所有受影響的節點必須重新開機,
CloudInit配置才會生效。
一旦配置套用後,任何嘗試使用 SSH 密碼存取 Harvester 節點的操作都會被拒絕。
$ ssh -o PreferredAuthentications=password rancher@<node-ip>
rancher@<node-ip>: Permission denied (publickey,keyboard-interactive).