git配置sshkey
生成密钥对
ssh-keygen -t ed25519 -C "your_email@example.com"
#or
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f D:\ssh\github_id_rsa
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f D:\ssh\gitee_id_rsa
选项
- -b:指定密钥长度;
- -e:读取openssh的私钥或者公钥文件;
- -C:添加注释;
- -f:指定用来保存密钥的文件名;
- -i:读取未加密的ssh-v2兼容的私钥/公钥文件,然后在标准输出设备上显示openssh兼容的私钥/公钥;
- -l:显示公钥文件的指纹数据;
- -N:提供一个新密语;
- -P:提供(旧)密语;
- -q:静默模式;
- -t:指定要创建的密钥类型。
配置config文件
在 C:\Users\liugang\.ssh
文件夹添加config文件
Host github.com
HostName github.com
User your_email@example.com
PreferredAuthentications publickey
IdentityFile D:\ssh\github_id_rsa
Host gitee.com
HostName gitee.com
User your_email@example.com
PreferredAuthentications publickey
IdentityFile D:\ssh\gitee_id_rsa
用ssh进行git操作
第一次使用需要生成指纹