vuepress push代码时报错:Permission denied (publickey). fatal: Could not read from remote repository.

本文针对用vuepress和github page搭建博客。其中的deploy.sh文件配置。

参考博客

----------------------开始上传------------------------
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
npm ERR! code ELIFECYCLE
npm ERR! errno 128
npm ERR! lanye233blog@1.0.0 deploy: `bash deploy.sh`
npm ERR! Exit status 128
npm ERR! 
npm ERR! Failed at the lanye233blog@1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

在deploy.sh中将push代码里的https地址换为ssh地址

echo "----------------------开始上传------------------------"
sudo git push -f https://github.com/xxx/xxx.github.io.git master
# git@github.com:xxx/xxx.github.io.git
# https://github.com/xxx/xxx.github.io.git
echo "----------------------上传完毕------------------------"

成功上传

----------------------开始上传------------------------
Enumerating objects: 56, done.
Counting objects: 100% (56/56), done.
Delta compression using up to 8 threads
Compressing objects: 100% (53/53), done.
Writing objects: 100% (56/56), 5.84 MiB | 208.00 KiB/s, done.
Total 56 (delta 6), reused 0 (delta 0)
remote: Resolving deltas: 100% (6/6), done.
To https://github.com/xxx/xxx.github.io.git
 + 413df59...afef7ae master -> master (forced update)
----------------------上传完毕------------------------
该错误消息 "git@github.com: Permission denied (publickey). fatal: Could not read from remote repository." 表明在尝试使用git命令出现了权限问题,导致无法读取远程仓库。 这个错误通常是因为未正确配置或提供了正确的SSH密钥。SSH密钥用于身份验证,以便与远程仓库进行通信。 要解决此问题,您可以按照以下步骤进行操作: 1. 确认您已经生成了正确的SSH密钥对。您可以通过运行以下命令来检查是否已经生成了SSH密钥对: ``` ls -al ~/.ssh ``` 如果没有生成SSH密钥对,您可以使用以下命令生成: ``` ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 请将"your_email@example.com"替换为您在GitHub上注册使用的电子邮件地址。 2. 确保您已经将公钥添加到GitHub帐户。您可以使用以下命令来复制并显示公钥: ``` cat ~/.ssh/id_rsa.pub ``` 您需要将输出的公钥内容复制到GitHub帐户的SSH密钥设置中。 3. 确认您的本地git仓库的远程URL是否正确。您可以使用以下命令来检查远程URL: ``` git remote -v ``` 如果远程URL不正确,您可以使用以下命令来更改远程URL: ``` git remote set-url origin <new_remote_url> ``` 将"<new_remote_url>"替换为正确的GitHub仓库URL。 完成上述步骤后,再次尝试使用git push命令进行推送操作,应该就能够成功连接到远程仓库并推送您的更改了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [git@github.com: Permission denied (publickey).](https://blog.csdn.net/helloasimo/article/details/123778112)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.](https://blog.csdn.net/weixin_37707670/article/details/120616809)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值