gitosis 要求输入密码

发布于 2024-10-15 11:12:37 字数 487 浏览 2 评论 0原文

我已经按照

  • 使用 ssh-keygen 创建了一个 rsa 密钥对,文件名为 johndoe。
  • 然后将其复制到 gitosis admin repo 中的 keydir 中。
  • 编辑 gitosis 配置文件并将用户 johndoe 添加到成员列表中
  • 使用 git commit -a -m "what i did" 提交更改
  • 将更改推送到服务器

之后我尝试使用新的密钥文件。它要求输入密码,当我正确输入密码时,它会要求用户 git 的密码! 用户 git 没有密码。

现在我已经在 sshd_config 中关闭了密码身份验证,现在它显示“权限被拒绝(公钥)”。我检查了git用户的authorized_keys文件,里面只有一个密钥被授权,即gitosis管理员的初始密钥。

我还仔细检查了 ./gitosis-admin.git/hooks/post-update 挂钩上的权限,它有 755

I have setup a gitosis server following instructions from here. It works fine for the initial user but I have recently added a new user. Here are the steps I took.

  • Created an rsa keypair using ssh-keygen with filename johndoe.
  • Then copied it to the keydir in gitosis admin repo.
  • Edited the gitosis config file and added user johndoe to the list of members
  • Commited the changes using git commit -a -m "what i did"
  • Pushed the changes to the server

After that I tried to check out with the new keyfile. It asks for the passphrase and when I enter it correctly, it the asks for the password for user git!!!
There is not password for user git.

Now I have turned off PasswordAuthentication in sshd_config and now it says 'Permission denied (publickey). I have checked the git user's authorized_keys file and only one key is authorized inside it, i.e. the initial key for the gitosis admin.

I have also double checked the permissions on the ./gitosis-admin.git/hooks/post-update hook and it has 755

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

烟雨凡馨 2024-10-22 11:12:37

Gitosis 有点愚蠢——你用于密钥文件的文件名字面意思是“johndoe”吗?如果是这样,请更改它:

git mv keydir/johndoe keydir/johndoe.pub
git commit -m "changed key name"
git push

然后重试。

另外,正如 Arlen Cuss 指出的那样,请确保它实际上是公钥,而不是私钥。

Gitosis is kind of stupid — is the filename you used for the keyfile literally "johndoe"? If so, change that:

git mv keydir/johndoe keydir/johndoe.pub
git commit -m "changed key name"
git push

and try again.

Also, as Arlen Cuss points out, make sure it actually is the public key, not the private key.

如果没结果 2024-10-22 11:12:37

你好,我也遇到了同样的问题,最后找到了解决办法。

我必须遵循许多网站给出的说明,但每次之后

git clone git@[serveur_name]:gitosis-admin.git

它都会询问 GIT 的密码。

解决:
我已将管理公钥(在我的客户端用户上创建的公钥;然后导入到服务器的 tmp 目录中)插入到我的 authorized_keys 文件(位于 /home/git/.ssh/ 中) 服务器的目录)并且它现在可以工作了。

 cp authorized_keys authorized_keys.bak
 cat /tmp/id_dsa_git.pub >> authorized_keys

我发现了这个@ http://fclose.com/b/linux /366/set-up-git-server-through-ssh-connection/

Hi, I had the same problem, and I finally found a way out.

I had to follow the instructions given by many websites, but each time after

git clone git@[serveur_name]:gitosis-admin.git

It was asking password for GIT.

Resolution:
I have inserted the admin public key (the one created on my client user; then imported into the server's tmp directory) inside my authorized_keys file (located in the /home/git/.ssh/ directory of the server) and it works now.

 cp authorized_keys authorized_keys.bak
 cat /tmp/id_dsa_git.pub >> authorized_keys

I found this @ http://fclose.com/b/linux/366/set-up-git-server-through-ssh-connection/

生生漫 2024-10-22 11:12:37

确保您将公钥放入 gitosis 存储库中,而不是您的私有密钥!

生成密钥文件时,您将获得一个 .pub 文件 - 使用该文件,但将名称放入 gitosis.conf 中,不带 .pub< /代码>。

Make sure you're putting your public key inside your gitosis repo, and not your private one!

When you generate a keyfile, you'll get a .pub file—use that one, but put the name in your gitosis.conf without the .pub.

自由如风 2024-10-22 11:12:37

确保您还添加 (git add) .pub 文件,并将它们正确提交并推送到存储库。

Make sure you have also added (git add) the .pub-files, and committed and pushed them properly to the repository.

帅气尐潴 2024-10-22 11:12:37

我最近在工作的私人存储库中遇到了这个问题。我偶然发现了这个答案并阅读了答案; 这个这个 成功了。

为了给后代总结一下,请确保将 .pub 键添加到 gitosis-admin/keydir 目录中。它必须是 .pub 文件。

提交并提交将您的更改推送到gitosis-admin

您的 ~/.ssh/authorized_keys 将自动更新,因此无需将公钥文件的输出重定向到它。

希望这有帮助

I recently ran into this issue with a private repository for work. I came across this answer and read the answers; this and this did the trick.

To sum it up for posterity, make sure you add the .pub key to the gitosis-admin/keydir directory. It has to be a .pub file.

Commit & Push your changes to gitosis-admin.

Your ~/.ssh/authorized_keys will be automatically updated so no need to cat-redirect the output of your public key file to it.

Hope this helps

莫相离 2024-10-22 11:12:37

Windows 用户经常出错的一件事是,大多数教程都没有注意到这一点(因为他们假设您使用的是 Linux 客户端)

msysgit,Windows git 控制台,正在寻找您的私钥/home/YOURUSERNAME/.ssh/id_rsa
在Windows上是(Windows 7)C:\ Users \ YOURUSERNAME.ssh \ id_rsa

,而大多数人都正确使用该文件夹,因为它是自动创建的,他们错过了该文件必须命名为“id_rsa” 否则 msysgit 不会使用它。
我没有找到告诉 msysgit 使用其他键的方法

one thing that often goes wrong for windows users and isn't catched by most of the tutorials out there (since they assume you're on a linux client)

msysgit, the windows git console, is looking for your private key at /home/YOURUSERNAME/.ssh/id_rsa
which at windows is (Windows 7) C:\Users\YOURUSERNAME.ssh\id_rsa

while most get it right with the folder, since its created automaticly, they miss that the file HAS TO be named "id_rsa" or it wont be used by msysgit.
I didn't find a way to tell msysgit to use other keys

笑看君怀她人 2024-10-22 11:12:37

最有可能发生的情况是更新后挂钩未正常运行。

检查 ~git/.ssh/authorized_keys 中是否有您的公钥。

如果没有,则更新后挂钩不会运行。随后更改了哪些权限?其他一些配置错误。从别处复制的?

  1. 在服务器上,签出 gitosis admin:git clone /path/to/gitosis-admin.git。对 gitosis.conf 进行微小的更改。检查您的公钥是否在 keydir 中。我必须以 git 用户身份运行它。

  2. 提交gitosis.conf。 git add gitosis.conf && git commit -m“刷新密钥”。

  3. 现在检查authorized_keys 文件。

  4. 更改 gitosis.conf 并再次提交。

测试访问。如果在此过程之后authorized_keys 未更新,请在日志中查找错误消息。

Most likely what happened is that the post-update hook didn't run properly.

Check that ~git/.ssh/authorized_keys has your public key in it.

If not, the post-update hook didn't run. Permissions which have subsequently been changed? Some other configuration error. Copied from somewhere else?

  1. On the server, checkout gitosis admin: git clone /path/to/gitosis-admin.git. Make an insignificant change to gitosis.conf. Check that your public key is in keydir. I had to run this as the git user.

  2. Commit gitosis.conf. git add gitosis.conf && git commit -m "refresh keys".

  3. Now check authorized_keys file.

  4. Change gitosis.conf back and commit again.

Test access. If authorized_keys isn't updated after this process, look in logs for error messages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文