bash git clone 不要求用户密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34099843/
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
git clone without asking for users password
提问by sebastian_t
I want to create public git repository on my dedicated server for anyone to clone but it keeps asking me for password for git user.
我想在我的专用服务器上创建公共 git 存储库供任何人克隆,但它一直要求我输入 git 用户的密码。
I have created user named git without password. Used:
我创建了没有密码的名为 git 的用户。用过的:
passwd -d git
密码 -d git
Unfortunately every time I try to do:
不幸的是,每次我尝试这样做时:
git clone git@myhost:myrepo.git
git 克隆 git@myhost:myrepo.git
I'm getting asked for password.
我被要求输入密码。
I have tried setting in sshd_config
我试过设置 sshd_config
Match user git
PermitEmptyPasswords yes
PasswordAuthentication yes
With either yes and no for PasswordAuthentication
but still no use.
使用 yes 和 no forPasswordAuthentication
但仍然没有用。
采纳答案by sebastian_t
It seems doing it over ssh is impossible. It will always ask for password unless you copy your public key.
似乎通过 ssh 来做这件事是不可能的。除非您复制公钥,否则它将始终要求输入密码。
The solution is to use git daemon
and clone repository over git:// protocol
解决方案是git daemon
通过 git:// 协议使用和克隆存储库
git clone git://hostname/directory
git clone git://hostname/directory
For more information about it I suggest git help daemon
有关它的更多信息,我建议 git help daemon
Tip:
Remember you need to give it read privileges. From my experience setting others: chmod -R o+r project.git
won't work for some reason. You have to permit git access via either author or group. You can disallow write access to your repo on daemon level ( default behaviour ).
提示:请记住,您需要为其授予读取权限。根据我设置其他人的经验:chmod -R o+r project.git
由于某种原因不起作用。您必须允许通过作者或组访问 git。您可以禁止在守护程序级别(默认行为)对您的存储库进行写访问。
回答by Alsan
Same procedure as setup passwordless ssh login.
与设置无密码 ssh 登录的过程相同。
generate a passphase less private/public key pair
ssh-keygen <your-key-filename>
ssh-copy-id to your host server
add a config file under your client .ssh folder (note: this step is optional), the contents of the config file similar to the following:
Host <git-server> Hostname <ip-of-your-git-server> User <your-git-user-name> Port <your-git-server-port> IdentityFile <path-to-your-private-key>
try to login your host through ssh:
ssh <git-server>
now you can clone, push, pull, whatever to your git-server
生成无密码的私钥/公钥对
ssh-keygen <your-key-filename>
ssh-copy-id 到您的主机服务器
在你的客户端.ssh文件夹下添加一个配置文件(注意:这一步是可选的),配置文件的内容类似如下:
Host <git-server> Hostname <ip-of-your-git-server> User <your-git-user-name> Port <your-git-server-port> IdentityFile <path-to-your-private-key>
尝试通过 ssh 登录您的主机:
ssh <git-server>
现在你可以克隆、推送、拉取任何东西到你的 git-server
Edit: try to google "password less ssh login" for more detail and tricks.
编辑:尝试谷歌“无密码 ssh 登录”以获取更多详细信息和技巧。