简体   繁体   English

git clone:权限被拒绝(公钥),使用Debian

[英]git clone : Permission denied (publickey) Using Debian

I didn't find the solution to my problem in similar questions. 在类似的问题中,我没有找到解决问题的方法。

Here is what i try to get : 这是我想要得到的:

  • to clone my server side git repo on a client machine 在客户端计算机上克隆我的服务器端git repo

Command that doesn't work (from the client machine) : 无效的命令 (从客户端计算机):

sudo git clone myuser@servermachine:/path_to_repo/repo.git

I'm getting the error: 我收到错误消息:

Cloning into 'repo'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Note: i can login with ssh to the server machine (from the client machine) : 注意:我可以使用ssh登录到服务器计算机(从客户端计算机):

ssh myuser@servermachine

--> ok i'm logged in, without being asked for a password ->好的,我已登录,无需输入密码

What i already did : 我已经做了什么:

  • 'ssh-keygen' on my client machine 我的客户端计算机上的“ ssh-keygen”
  • copied ~/.ssh/id_rsa.pub (from client machine) to ~/.ssh/authorized_keys (on server machine) 将〜/ .ssh / id_rsa.pub(从客户端计算机)复制到〜/ .ssh / authorized_keys(在服务器计算机上)

Additional note : 补充说明:

This exact same clone command works fine from another client machine : 这个完全相同的克隆命令可以在另一台客户端计算机上正常工作:

git clone myuser@servermachine:/path_to_repo/repo.git

It should be pretty straightforward but i'm out of idea :'( Anyone got an idea ? 它应该很简单,但是我不知道该怎么做:'(有人知道吗?

Ok i finally get it to work. 好吧,我终于得到它的工作。

I mixed up my command with "sudo" and this was the main reason it did't work 我将命令与“ sudo”混淆了,这是它不起作用的主要原因

What i did is : 我所做的是:

  • I earesed all the lines on my server machine in file ~/.ssh/known_hosts 我将服务器计算机上的所有行都记录在〜/ .ssh / known_hosts文件中
  • I cd in a folder i have access to (from client machine), like in ~/ 我将CD放入我可以从客户端计算机访问的文件夹中,例如〜/
  • I started again the same command, without the sudo, and it worked, hooray ! 我再次启动了相同的命令,但没有sudo,它起作用了,万岁!

That is : 那是 :

git clone myuser@servermachine:/path_to_repo/repo.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM