当前位置:   article > 正文

linux 下git出现 Permission denied (publickey). fatal: 无法读取远程仓库。_linuxgit@code.cestc.cn: permission denied (publick

linuxgit@code.cestc.cn: permission denied (publickey). fatal: could not read

背景: 

  1. marhal@php-ubuntu18:/var/www/html$ composer create-project laravel/laravel Laravel-1 --prefer-dist "5.8.*"
  2. marhal@php-ubuntu18:/var/www/html/Laravel-1$ sudo chown -R www-data:www-data bootstrap/
  3. marhal@php-ubuntu18:/var/www/html/Laravel-1$ sudo chown -R www-data:www-data storage/
  4. marhal@php-ubuntu18:/var/www/html/Laravel-1$ cd
  5. marhal@php-ubuntu18:~$ git config --global user.name 'Marhal'
  6. marhal@php-ubuntu18:~$ git config --global user.email 'xxxxxx@sina.com'
  7. marhal@php-ubuntu18:~$ git config --global push.default simple
  8. marhal@php-ubuntu18:~$ cd /var/www/html/Laravel-1/
  9. marhal@php-ubuntu18:/var/www/html/Laravel-1$ git init
  10. 已初始化空的 Git 仓库于 /var/www/html/Laravel-1/.git/
  11. marhal@php-ubuntu18:/var/www/html/Laravel-1$ git add -A
  12. marhal@php-ubuntu18:/var/www/html/Laravel-1$ git commit -m "init projext"
  13. marhal@php-ubuntu18:/var/www/html/Laravel-1$ git remote add origin git@code.aliyun.com:Marhal/Laravel-1.git
  14. marhal@php-ubuntu18:/var/www/html/Laravel-1$ git push -u origin master
  15. The authenticity of host 'code.aliyun.com (120.55.150.20)' can't be established.
  16. RSA key fingerprint is SHA256:ZrA2ZqYTVyPbw4zytCSAv74ZMaS2LDH74I7sMPtQIG0.
  17. Are you sure you want to continue connecting (yes/no)? yes
  18. Warning: Permanently added 'code.aliyun.com,120.55.150.20' (RSA) to the list of known hosts.
  19. git@code.aliyun.com: Permission denied (publickey).
  20. fatal: 无法读取远程仓库。
  21. 请确认您有正确的访问权限并且仓库存在。

解决方案:

marhal@php-ubuntu18:~$ ssh-keygen -t rsa -C "xxxx@sina.com"

一路回车

  1. marhal@php-ubuntu18:~$ cd /home/marhal/.ssh/
  2. marhal@php-ubuntu18:~/.ssh$ ls
  3. id_rsa id_rsa.pub known_hosts
  4. marhal@php-ubuntu18:~/.ssh$ cat id_rsa.pub
  5. ssh-rsa 密钥内容 xxxxx@sina.com

复制 id_rsa.pub 的内容到代码托管平台添加ssh密钥。

添加以后测试是否成功

  1. marhal@php-ubuntu18:~$ ssh code.aliyun.com
  2. Connection to code.aliyun.com closed by remote host.
  3. Connection to code.aliyun.com closed.

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/418145
推荐阅读
相关标签
  

闽ICP备14008679号