#requires -RunAsAdministrator # 添加 Mac 公钥到 Windows authorized_keys $MacKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDuLPlB6X9JC2uP9urgA94wCr7VBPKAX+4j9hR5wc5U5rPDxhKWbFBzRiFU/cssCZlcZbuoWPjrxwtTKR6Tq1++ugHffa2poulXCoufaN5s9kN6US8DNe/q7dulAomwd0pjSDTjhQR4OQG847PqfXz/quU96RfpOrn1WqSRTrzPnVZ885ApNUB7SHd74jrYslwoDRsJu+mS6jjI7NHdNUKTAUBsZWWPmjNO4X1+vEwwK6dZg9i1Z+sz5kLxZ0w+fI1hO6rtR5MPZh8G9JRWiVw3HN0vQtf3zxYtDnzPxELfiE10cctDaDqwMKZ6K73WNlkmoNuM7we7eRlarPGWmGu9 houzi@MichaeldeMBP.lan" $AuthKeys = "C:\Users\houzi\.ssh\authorized_keys" Write-Host "=== 添加 Mac 公钥到 Windows ===" -ForegroundColor Cyan Write-Host "" # 检查是否已存在 $content = Get-Content $AuthKeys -Raw -ErrorAction SilentlyContinue if ($content -match "houzi@MichaeldeMBP.lan") { Write-Host "Mac 公钥已存在,无需添加" -ForegroundColor Yellow } else { Write-Host "添加 Mac 公钥..." -ForegroundColor Yellow Add-Content -Path $AuthKeys -Value $MacKey -Encoding ASCII Write-Host "✓ 已添加" -ForegroundColor Green } Write-Host "" Write-Host "=== 当前 authorized_keys 内容 ===" -ForegroundColor Cyan Get-Content $AuthKeys Write-Host "" Write-Host "完成!" -ForegroundColor Green