-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-github-ssh.sh
More file actions
executable file
·41 lines (35 loc) · 1.29 KB
/
Copy pathtest-github-ssh.sh
File metadata and controls
executable file
·41 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# GitHub SSH 连接测试脚本
echo "🔐 测试 GitHub SSH 连接..."
echo ""
# 测试 SSH 连接
if ssh -T git@github.com 2>&1 | grep -q "successfully authenticated"; then
echo "✅ SSH 连接成功!"
echo ""
echo "现在可以使用推送脚本:"
echo " ./push-to-github.sh"
echo ""
# 显示当前 Remote 配置
echo "📍 当前 Remote 配置:"
git remote -v
elif ssh -T git@github.com 2>&1 | grep -q "Permission denied"; then
echo "❌ SSH 密钥未添加到 GitHub"
echo ""
echo "请按以下步骤添加 SSH 密钥:"
echo "1. 复制下面的公钥:"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
cat ~/.ssh/id_ed25519.pub
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "2. 打开 https://github.com/settings/keys"
echo "3. 点击 'New SSH key'"
echo "4. Title: MacBook Logic IDE"
echo "5. Key: 粘贴上面的公钥"
echo "6. 点击 'Add SSH key'"
echo ""
echo "添加完成后再次运行: ./test-github-ssh.sh"
else
echo "🔄 正在测试连接..."
ssh -T git@github.com
fi