windows下生成SSH密钥
# 生成密钥
ssh-keygen -t rsa -C "youremail@example.com"
1
或者直接
ssh-keygen
1
密钥类型可以用 -t
选项指定。如果没有指定则默认生成用于SSH-2
的RSA
密钥。这里使用的是rsa
。
同时在密钥中有一个注释字段,用-C来指定所指定的注释,可以方便用户标识这个密钥,指出密钥的用途或其他有用的信息。所以在这里输入自己的邮箱或者其他都行。
密码可以为空,直接回车跳过。
此时 [c盘
> 用户
> 自己的用户名
> .ssh
] 目录下已经生成好了,id_rsa.pub
就是所以要的密钥文件。
# 如发现在添加好密钥后还是提示权限问题
密钥已经部署到 git
仓库后,clone
还是提示权限问题
Cloning into '.'...
git@e.coding.net: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
1
2
3
4
5
6
2
3
4
5
6
执行:ssh-add
如出现:Could not open a connection to your authentication agent
时
执行:ssh-agent bash
在执行:ssh-add
在clone
就没问题了
上次更新: 2024/01/12, 11:30:32