π docs: update ssh-keys
swadhinbiswas committed 3 months ago
1938743
1 parent ea811be
commit 1938743
1 file changed
+120 -0
Showing 1 changed file+120-0
βΌdocs/getting-started/ssh-keys.md
+120-0
| @@ -0,0 +1,120 @@ | ||
1 | +--- | |
2 | +title: "SSH Keys & Deploy Keys" | |
3 | +description: "How to set up SSH keys for secure Git operations and deploy keys for CI/CD" | |
4 | +--- | |
5 | + | |
6 | +# SSH Keys & Deploy Keys | |
7 | + | |
8 | +OpenCodeHub supports SSH key authentication for secure Git operations without passwords. | |
9 | + | |
10 | +## SSH Keys (Account-Level) | |
11 | + | |
12 | +SSH keys give you access to **all your repositories**. Use them for daily development. | |
13 | + | |
14 | +### Generating an SSH Key | |
15 | + | |
16 | +**Ed25519 (recommended):** | |
17 | +```bash | |
18 | +ssh-keygen -t ed25519 -C "[email protected]" | |
19 | +``` | |
20 | + | |
21 | +**RSA (legacy):** | |
22 | +```bash | |
23 | +ssh-keygen -t rsa -b 4096 -C "[email protected]" | |
24 | +``` | |
25 | + | |
26 | +### Adding Your Key | |
27 | + | |
28 | +1. Copy your public key: | |
29 | + ```bash | |
30 | + cat ~/.ssh/id_ed25519.pub | |
31 | + ``` | |
32 | + | |
33 | +2. Go to **Settings β SSH Keys** in OpenCodeHub | |
34 | + | |
35 | +3. Click **New SSH Key** | |
36 | + | |
37 | +4. Paste your public key and give it a title (e.g., "Work Laptop") | |
38 | + | |
39 | +### Testing Your Connection | |
40 | + | |
41 | +```bash | |
42 | +ssh -T [email protected] | |
43 | +``` | |
44 | + | |
45 | +You should see: `Hi username! You've successfully authenticated` | |
46 | + | |
47 | +> **Note:** Replace `your-server.com` with your actual OpenCodeHub server hostname or IP address. | |
48 | + | |
49 | +### Using SSH with Git | |
50 | + | |
51 | +```bash | |
52 | +# Clone via SSH | |
53 | +git clone [email protected]:owner/repo.git | |
54 | + | |
55 | +# Add SSH remote to existing repo | |
56 | +git remote add origin [email protected]:owner/repo.git | |
57 | +``` | |
58 | + | |
59 | +## Deploy Keys (Repository-Level) | |
60 | + | |
61 | +Deploy keys grant access to a **single repository**. Use them for CI/CD and deployments. | |
62 | + | |
63 | +### When to Use Deploy Keys | |
64 | + | |
65 | +- CI/CD pipelines that need to pull code | |
66 | +- Deployment servers | |
67 | +- Automation scripts with limited access | |
68 | + | |
69 | +### Generating a Deploy Key | |
70 | + | |
71 | +```bash | |
72 | +ssh-keygen -t ed25519 -C "deploy@production-server" | |
73 | +``` | |
74 | + | |
75 | +### Adding a Deploy Key | |
76 | + | |
77 | +1. Go to **Repository β Settings β Deploy Keys** | |
78 | + | |
79 | +2. Click **Add deploy key** | |
80 | + | |
81 | +3. Paste the public key and give it a title | |
82 | + | |
83 | +4. Choose **Read-only** or **Read/write** access | |
84 | + | |
85 | +### Key Differences | |
86 | + | |
87 | +| Feature | SSH Keys | Deploy Keys | | |
88 | +|---------|----------|-------------| | |
89 | +| Scope | All repositories | Single repository | | |
90 | +| Access | Full account access | Read-only or read/write | | |
91 | +| Use case | Daily development | CI/CD, deployment | | |
92 | + | |
93 | +## Troubleshooting | |
94 | + | |
95 | +### Permission Denied | |
96 | + | |
97 | +```bash | |
98 | +# Check SSH agent | |
99 | +ssh-add -l | |
100 | + | |
101 | +# Add key to agent | |
102 | +ssh-add ~/.ssh/id_ed25519 | |
103 | + | |
104 | +# Debug SSH connection | |
105 | +ssh -vvv [email protected] | |
106 | +``` | |
107 | + | |
108 | +### Wrong Key Being Used | |
109 | + | |
110 | +```bash | |
111 | +# Specify key explicitly | |
112 | +ssh -i ~/.ssh/id_ed25519 [email protected] | |
113 | +``` | |
114 | + | |
115 | +### Host Key Verification Failed | |
116 | + | |
117 | +```bash | |
118 | +# Add host to known_hosts | |
119 | +ssh-keyscan your-server.com >> ~/.ssh/known_hosts | |
120 | +``` | |
0 | 121 | |