feat: add ex
This commit is contained in:
172
ssh公私钥配置.md
172
ssh公私钥配置.md
@@ -1,8 +1,172 @@
|
||||
# 配置ssh密钥快速指南
|
||||
|
||||
配置密钥可以实现快速登录就是了
|
||||
|
||||
运行监听tls证书的脚本pod,会初始化ssh公私钥
|
||||
将公钥复制到被连接服务器对应用户的.ssh/authorized_key里面保存
|
||||
# 快速指南:生成 SSH 密钥对用于 Git
|
||||
|
||||
**重点**
|
||||
需要进入该pod手动进行一次ssh连接,目的是接受并保存指纹信息,脚本自动监听并没有这个机制,但是这是必须的
|
||||
## 1. 检查现有 SSH 密钥
|
||||
|
||||
### Linux / macOS
|
||||
|
||||
```bash
|
||||
ls -al ~/.ssh
|
||||
```
|
||||
|
||||
### Windows(PowerShell / 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"
|
||||
```
|
||||
|
||||
### Windows(PowerShell / 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"
|
||||
```
|
||||
|
||||
### Windows(PowerShell / 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
|
||||
```
|
||||
|
||||
### Windows(PowerShell / 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
|
||||
```
|
||||
|
||||
### Windows(PowerShell / 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 优先**:更安全、更短更快
|
||||
- **私钥妥善保管**:不要上传到任何平台
|
||||
- **不同机器不同密钥**:每台设备建议生成独立密钥
|
||||
- **密码短语保护**:防止密钥泄露被直接使用
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 利用scp和ssh实现中转服务器证书配置自动同步
|
||||
# 利用ssh实现中转服务器证书配置自动同步
|
||||
|
||||
**背景**
|
||||
|
||||
17
基于helm chart部署gitea的配置问题.md
Normal file
17
基于helm chart部署gitea的配置问题.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# 基于helm chart部署gitea的配置问题
|
||||
|
||||
#### chart对于gitea数量庞大的配置项的处理
|
||||
|
||||
chart包是这样做的:
|
||||
|
||||
先将values的config下的内容进行base64处理,会一起放入创建的secret里
|
||||
|
||||
然后,gitea所在的pod会执行三个初始化操作,分别是创建目录,写入配置,应用配置
|
||||
|
||||
最终gitea读取配置并启动
|
||||
|
||||
### 注意
|
||||
|
||||
配置的时候,需要对应官方文档中的配置条目,对应的配置键值对要位于正确的上层位置
|
||||
|
||||
还有一件事,如果你是多配置->少配置,secret的更新规则像是git中的merge,需要手动删除整个secret重新创建,否则会有垃圾配置项干扰判断
|
||||
Reference in New Issue
Block a user