feat: add ex

This commit is contained in:
2025-10-19 23:17:49 +08:00
parent 10c78887b0
commit 0dd0772dc9
3 changed files with 186 additions and 5 deletions

View File

@@ -1,8 +1,172 @@
# 配置ssh密钥快速指南 # 配置ssh密钥快速指南
配置密钥可以实现快速登录就是了 配置密钥可以实现快速登录就是了
运行监听tls证书的脚本pod会初始化ssh公私钥 # 快速指南:生成 SSH 密钥对用于 Git
将公钥复制到被连接服务器对应用户的.ssh/authorized_key里面保存
**重点** ## 1. 检查现有 SSH 密钥
需要进入该pod手动进行一次ssh连接目的是接受并保存指纹信息脚本自动监听并没有这个机制但是这是必须的
### Linux / macOS
```bash
ls -al ~/.ssh
```
### WindowsPowerShell / Git Bash
```powershell
# PowerShell
Get-ChildItem -Path $env:USERPROFILE\.ssh
# Git Bash
ls -al /c/Users/YourUserName/.ssh
```
常见文件:
- `id_rsa` / `id_rsa.pub`RSA 密钥对)
- `id_ed25519` / `id_ed25519.pub`ED25519 密钥对)
> ⚠️ 注意:如果已有密钥且希望复用,可跳过生成步骤。
---
## 2. 生成新的 SSH 密钥对
### 2.1 使用 ED25519推荐安全且快速
### Linux / macOS
```bash
ssh-keygen -t ed25519 -C "your_email@example.com"
```
### WindowsPowerShell / Git Bash
```powershell
# Git Bash / PowerShell
ssh-keygen -t ed25519 -C "your_email@example.com"
```
- `-C` 用于添加备注(通常填写邮箱)
- 系统会提示:
- **文件名**(默认 `~/.ssh/id_ed25519``C:\Users\YourUserName\.ssh\id_ed25519`
- **密码短语**(可选,用于额外保护私钥)
### 2.2 使用 RSA兼容性更好但略旧
### Linux / macOS
```bash
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```
### WindowsPowerShell / Git Bash
```powershell
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```
- `-b 4096` 指定密钥长度,推荐 4096 位
---
## 3. 添加 SSH 私钥到 SSH Agent
### Linux / macOS
1. 启动 ssh-agent
```bash
eval "$(ssh-agent -s)"
```
2. 添加私钥:
```bash
ssh-add ~/.ssh/id_ed25519
# 或者 RSA 私钥
ssh-add ~/.ssh/id_rsa
```
### WindowsPowerShell / Git Bash
1. 启动 ssh-agent 服务:
```powershell
# PowerShell
Start-Service ssh-agent
# 设置为开机自启(可选)
Set-Service -Name ssh-agent -StartupType Automatic
```
2. 添加私钥:
```powershell
ssh-add C:\Users\YourUserName\.ssh\id_ed25519
# 或者 RSA 私钥
ssh-add C:\Users\YourUserName\.ssh\id_rsa
```
> 🔑 如果你设置了密码短语,需要在此步骤输入一次。
---
## 4. 将公钥添加到 Git 账号
### Linux / macOS
```bash
cat ~/.ssh/id_ed25519.pub
```
### WindowsPowerShell / Git Bash
```powershell
# PowerShell
Get-Content C:\Users\YourUserName\.ssh\id_ed25519.pub
# Git Bash
cat /c/Users/YourUserName/.ssh/id_ed25519.pub
```
然后登录 Git 平台GitHub、GitLab、Gitee 等)添加公钥。
---
## 5. 测试连接
### Linux / macOS / Windows
```bash
ssh -T git@github.com
```
- 第一次连接可能提示是否继续,输入 `yes`
- 成功提示示例:
```
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
```
---
## 6. 配置 Git 使用 SSH
### Linux / macOS / Windows
```bash
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
git remote set-url origin git@github.com:username/repo.git
```
- 确保远程仓库使用 **SSH 地址** 而不是 HTTPS
---
## ✅ 小贴士
- **ED25519 优先**:更安全、更短更快
- **私钥妥善保管**:不要上传到任何平台
- **不同机器不同密钥**:每台设备建议生成独立密钥
- **密码短语保护**:防止密钥泄露被直接使用

View File

@@ -1,4 +1,4 @@
# 利用scp和ssh实现中转服务器证书配置自动同步 # 利用ssh实现中转服务器证书配置自动同步
**背景** **背景**

View File

@@ -0,0 +1,17 @@
# 基于helm chart部署gitea的配置问题
#### chart对于gitea数量庞大的配置项的处理
chart包是这样做的
先将values的config下的内容进行base64处理会一起放入创建的secret里
然后gitea所在的pod会执行三个初始化操作分别是创建目录写入配置应用配置
最终gitea读取配置并启动
### 注意
配置的时候,需要对应官方文档中的配置条目,对应的配置键值对要位于正确的上层位置
还有一件事,如果你是多配置->少配置secret的更新规则像是git中的merge需要手动删除整个secret重新创建否则会有垃圾配置项干扰判断