#!/bin/bash
# 添加 Mac 的 ed25519 公钥到 Windows authorized_keys

ED25519_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEdDnOymO9MaCEwl8q6ewHKCwBHxDKDSud1orvUXEKz+ houzi"
AUTH_KEYS="/c/Users/houzi/.ssh/authorized_keys"

echo "=== 添加 ed25519 公钥到 Windows ==="
echo ""

# 检查是否已存在
if grep -q "AAAAC3NzaC1lZDI1NTE5AAAAIEdDnOymO9MaCEwl8q6ewHKCwBHxDKDSud1orvUXEKz+" "$AUTH_KEYS" 2>/dev/null; then
    echo "ed25519 公钥已存在，无需添加"
else
    echo "添加 ed25519 公钥..."
    echo "$ED25519_KEY" >> "$AUTH_KEYS"
    echo "✓ 已添加"
fi

echo ""
echo "=== 当前 authorized_keys (共 $(wc -l < "$AUTH_KEYS") 行) ==="
cat "$AUTH_KEYS"
echo ""
echo "完成！"
