[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
本文针对的是Windows生成SSH key,服务器端可以做参考。
当git clone报“Permission denied (publickey). fatal: Could not read from remote
repository.”
前置:需要下载git
场景:被拉到特定的git项目下需要本地配置ssh才能拉去代码,比如在公司。
1. 打开对应的目录,右键点击“Git Bash Here”,进入命令行 。
2. 如果你没有ssh key的话,在ternimal下输入命令:
ssh-keygen -t rsa -C “你的邮箱”
输入后一路回车即可,啥都不需要填,即会生成你的ssh key。(若重新生成的话会覆盖之前的ssh key。)
3. 执行命令:
ssh -v [email protected]
比如GitHub,当然也可以是其他的git仓库,把“@”后面的对应上即可。
最后大致会出现Permission denied (publickey).这句话。
4. 再执行命令
ssh-agent -s
会跳出SSH_AUTH_SOCK、SSH_AGENT_PID、echo Agent pid的信息才是执行成功。
这里可能遇到BUG:
Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent
service,error:1058"
解决:打开Windows PowerShell(Windows搜索栏或直接搜索本身带着的)
输入命令:
Get-Service ssh-agent
大概会出现这样的信息:
Status Name DisplayName ------ ---- ----------- Stopped ssh-agent OpenSSH
Authentication Agen
再输入命令:
Get-Service ssh-agent | Select StartType
大概会出现这样的信息:
StartType --------- Disabled
最后输入命令解决(只要您运行 ssh-agent,它就会启动该服务):
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
5. 再输入命令:
ssh-add ~/.ssh/id_rsa
正确来说会提示:Identity 。。。 (对应的路径信息)
如果报错,尝试输入命令,看能否解决:
eval ssh-agent -s
6、按上面的路径信息,把id_rsa.pub全部复制粘贴,在git仓库,个人设置的SSH key部分,输入这个复制内容,标题自定义,最后Add SSH
Key完成。