git gitosis 要求输入密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4882545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gitosis asking for password
提问by andho
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.
我已经按照此处的说明设置了 gitosis 服务器。它适用于初始用户,但我最近添加了一个新用户。这是我采取的步骤。
- 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
- 使用
ssh-keygen
文件名 johndoe创建了一个 rsa 密钥对。 - 然后将其复制到 gitosis admin repo 中的 keydir。
- 编辑 gitosis 配置文件并将用户 johndoe 添加到成员列表中
- 使用提交更改
git commit -a -m "what i did"
- 将更改推送到服务器
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.
之后,我尝试使用新的密钥文件进行检查。它要求输入密码,当我正确输入时,它要求输入用户 git 的密码!!!用户 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.
现在我在 sshd_config 中关闭了 PasswordAuthentication,现在它显示“权限被拒绝(公钥)”。我检查了 git 用户的 authorized_keys 文件,里面只有一个密钥被授权,即 gitosis 管理员的初始密钥。
I have also double checked the permissions on the ./gitosis-admin.git/hooks/post-update hook and it has 755
我还仔细检查了 ./gitosis-admin.git/hooks/post-update 钩子上的权限,它有 755
回答by ebneter
Gitosis is kind of stupid — is the filename you used for the keyfile literally "johndoe"? If so, change that:
Gitosis 有点愚蠢——您用于密钥文件的文件名是字面上的“johndoe”吗?如果是这样,请更改:
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 isthe public key, not the private key.
此外,正如 Arlen Cuss 指出的那样,确保它实际上是公钥,而不是私钥。
回答by lutinwood
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.
它正在询问 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.
解决方案:我已在我的authorized_keys
文件(位于服务器目录中)中插入了管理公钥(在我的客户端用户上创建的那个;然后导入到服务器的 tmp 目录中)/home/git/.ssh/
,现在它可以工作了。
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/
我发现这个@ http://fclose.com/b/linux/366/set-up-git-server-through-ssh-connection/
回答by Ashe
Make sure you're putting your public keyinside your gitosis repo, and not your private one!
确保你把你的公钥放在你的 gitosis 仓库里,而不是你的私人仓库里!
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
.
当你生成一个密钥.pub
文件时,你会得到一个文件——使用那个文件,但把名字放在你的名字中,gitosis.conf
不带.pub
.
回答by Marcus E
Make sure you have also added (git add) the .pub-files, and committed and pushed them properly to the repository.
确保您还添加了 (git add) .pub 文件,并将它们正确提交并推送到存储库。
回答by Zack
I recently ran into this issue with a private repository for work. I came across this answer and read the answers; thisand thisdid 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 .pubfile.
为后人总结一下,请确保将.pub
密钥添加到gitosis-admin/keydir
目录中。它必须是一个.pub文件。
Commit & Push your changes to gitosis-admin.
提交并将您的更改推送到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.
您~/.ssh/authorized_keys
将自动更新,因此无需将公钥文件的输出重定向到它。
Hope this helps
希望这可以帮助
回答by masi
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)
Windows 用户经常出错的一件事,并且大多数教程都没有发现(因为他们假设您使用的是 linux 客户端)
msysgit, the windows git console, is looking for your private key at /home/YOURUSERNAME/.ssh/id_rsawhich at windows is (Windows 7) C:\Users\YOURUSERNAME.ssh\id_rsa
msysgit,windows git 控制台,正在/home/YOURUSERNAME/.ssh/id_rsa寻找你的私钥,在 windows 是 (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
虽然大多数人都能正确使用该文件夹,但由于它是自动创建的,他们错过了该文件必须命名为“id_rsa”,否则 msysgit 将不会使用它。我没有找到告诉 msysgit 使用其他键的方法
回答by Interlated
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.
检查 ~git/.ssh/authorized_keys 中是否包含您的公钥。
If not, the post-update hook didn't run. Permissions which have subsequently been changed? Some other configuration error. Copied from somewhere else?
如果不是,则更新后挂钩未运行。随后更改的权限?其他一些配置错误。从别处抄来的?
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.
Commit gitosis.conf. git add gitosis.conf && git commit -m "refresh keys".
Now check authorized_keys file.
Change gitosis.conf back and commit again.
在服务器上,签出 gitosis admin:git clone /path/to/gitosis-admin.git。对 gitosis.conf 进行微不足道的更改。检查您的公钥是否在 keydir 中。我必须以 git 用户身份运行它。
提交 gitosis.conf。git add gitosis.conf && git commit -m “刷新密钥”。
现在检查authorized_keys 文件。
将 gitosis.conf 改回并再次提交。
Test access. If authorized_keys isn't updated after this process, look in logs for error messages.
测试访问。如果这个过程之后没有更新authorized_keys,请在日志中查找错误消息。