Commit dc2451
2024-05-03 13:33:05 Qwas: 新增 SSH| /dev/null .. SSH.md | |
| @@ 0,0 1,42 @@ | |
| + | # SSH |
| + | |
| + | ## 创建 SSH 密钥对 |
| + | |
| + | ```sh |
| + | ssh-keygen -t ed25519 -C "用户名@备注信息" |
| + | ``` |
| + | |
| + | > 引号中内容为备注信息,可以任意填写 |
| + | > |
| + | > 默认保存路径 ~/.ssh/ , 私钥: ~/.ssh/id_ed25519 , 公钥: ~/.ssh/id_ed25519.pub |
| + | |
| + | <details> |
| + | <summary> |
| + | 在不支持ed25519 算法的老旧系统中生成密钥 |
| + | </summary> |
| + | |
| + | ```sh |
| + | ssh-keygen -t rsa -b 4096 -C "用户名@备注信息" |
| + | ``` |
| + | </details> |
| + | |
| + | ## SSH 配置文件 |
| + | |
| + | 连接保活,每60秒发送一个 keep-alive 包 |
| + | |
| + | > cat ~/.ssh/config |
| + | |
| + | ```ini |
| + | ServerAliveInterval 60 |
| + | |
| + | # 开启ssh-agent转发 |
| + | Host * |
| + | ForwardAgent yes |
| + | |
| + | # 针对特定主机开启 ssh-agent 转发 |
| + | Host github |
| + | HostName github.com |
| + | IdentityFile ~/.ssh/id_ed25519 |
| + | User git |
| + | ForwardAgent yes |
| + | ``` |