git clone失败
来源:13-9 服务端项目自动化发布、验证、故障排查与解决
浣玉
2018-05-16
第一次使用ssh -T git@github.com,命令正确输出的
Hi HUANYU2015! You've successfully authenticated, but GitHub does not provide shell access.
但是使用sudo git clone ,,,后输出:
[yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ sudo git clone git@github.com:HUANYU2015/2017-05-12.git Cloning into '2017-05-12'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 不使用sudo则是这样:[yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ git clone git@github.com:HUANYU2015/2017-05-12.git fatal: could not create work tree dir '2017-05-12': Permission denied
然后重新产生ssh key,具体情况还是这样,ssh -T git@github.com验证通过,但是git clone 提示fatal: could not create work tree dir '2017-05-12': Permission denied 老师这是什么问题啊? 下面是重新生成ssh key的步骤: [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ ssh-keygen -t rsa -C "shuyunfengcsdn@gmail.com" Generating public/private rsa key pair. Enter file in which to save the key (/usr/yunyue/.ssh/id_rsa): /usr/yunyue/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /usr/yunyue/.ssh/id_rsa. Your public key has been saved in /usr/yunyue/.ssh/id_rsa.pub. The key fingerprint is: 39:5f:3d:75:a0:09:39:09:58:f2:30:37:61:69:d6:fc shuyunfengcsdn@gmail.com The key's randomart image is: +--[ RSA 2048]----+ | +oB*.o . | | .B+.*. o . | | o. oo o| | . E. ..| | S . o | | o . . | | . | | | | | +-----------------+ [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ ssh-add ~/.ssh/id_rsa Identity added: /usr/yunyue/.ssh/id_rsa (/usr/yunyue/.ssh/id_rsa) [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWhwPQwppM/1a0E48nbAJ5PJKpIxoPDS9EbqoveIwL8oMJGUKPhKe484L3+IGTWMvlplVf6ZG5tqMmo2wHARgBVDCxtQb1kO3QrvgZ/UtV3oNtdSabwNksX29H9cCSW2QwvP0BxcCIcsLZ/cBECeQ+ouUGHqR3gaO6hRHF0OAuKTAuKWSHBm2HKQG4QG+ex03Zo5gjsfgdB8wkN3KPlXI7r2kYvCk7xnAKZxh1o5Q+CP3uPlo2x1vt0SEYs4kwBJJs72sYNkgJS/R7W886fmEXHEjmE9jZRvZ+3whe9OAK8Hq9NxVzakaE0RvmbuAIaYGzByixS1ol+aE4WdSQRGnB shuyunfengcsdn@gmail.com [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ ssh -T git@github.com Hi HUANYU2015! You've successfully authenticated, but GitHub does not provide shell access. [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ ssh-add -l 2048 44:2f:bc:2a:3b:6d:be:22:db:1a:f5:6d:b7:2f:b4:a1 /usr/yunyue/.ssh/id_rsa (RSA) 2048 39:5f:3d:75:a0:09:39:09:58:f2:30:37:61:69:d6:fc /usr/yunyue/.ssh/id_rsa (RSA) [yunyue@iZ2ze9fstvjqgx02nvyip7Z git-repository]$ cd /usr/yunyue/.ssh/ [yunyue@iZ2ze9fstvjqgx02nvyip7Z .ssh]$ ll total 12 -rw------- 1 yunyue yunyue 1675 May 16 17:44 id_rsa -rw-r--r-- 1 yunyue yunyue 406 May 16 17:44 id_rsa.pub -rw-r--r-- 1 yunyue yunyue 802 May 16 17:13 known_hosts [yunyue@iZ2ze9fstvjqgx02nvyip7Z .ssh]$ cd /developer/ [yunyue@iZ2ze9fstvjqgx02nvyip7Z developer]$ ll total 56 drwxr-xr-x 6 root root 4096 May 13 22:03 apache-maven-3.5.0 drwxr-xr-x 9 root root 4096 May 11 11:55 apache-tomcat-9.0.0.M26 -rw-r--r-- 1 root root 1168 Apr 17 2017 deploy.sh drwxr-xr-x 2 root root 4096 May 16 16:42 gitdownload drwxr-xr-x 2 root root 4096 May 16 17:24 git-repository -rw-r--r-- 1 root root 25813 May 5 2017 mmall.sql drwxr-xr-x 2 root root 4096 May 14 18:08 mysql-server-5.7 drwxrwxrwx 4 root root 4096 May 16 12:15 setup [yunyue@iZ2ze9fstvjqgx02nvyip7Z developer]$ cd gitdownload/ [yunyue@iZ2ze9fstvjqgx02nvyip7Z gitdownload]$ git clone git@github.com:HUANYU2015/code.makery.ch.git fatal: could not create work tree dir 'code.makery.ch': Permission denied [yunyue@iZ2ze9fstvjqgx02nvyip7Z gitdownload]$
写回答
2回答
-
Geely
2018-05-19
私钥创建的时候是用的sudo创建还是普通用户创建的,这个还是有区别的。另外在github上填写了密钥了没?
看起来步骤没问题,应该就是权限问题啦。另外
atal: could not create work tree dir 'code.makery.ch': Permission denied
032018-05-31 -
polo哦
2018-05-17
权限问题 could not create work tree dir 'code.makery.ch': Permission denied
加sudo执行git clone试试
00
相似问题