[英]authorized_keys ignored for new git user
I want to create an own git server.我想创建一个自己的 git 服务器。 I started with a
root
user and here is the following I did:我从一个
root
用户开始,我做了以下事情:
mkdir /srv/git/project.git
useradd -r -d /srv/git git
passwd git
Now I have a new user git
(can log in via su git
from my root account).现在我有了一个新用户
git
(可以从我的 root 帐户通过su git
登录)。
I want to login via git@mywebsite.com
without the use of a password.我想在不使用密码的情况下通过
git@mywebsite.com
登录。 Right now, it will ask for a password every time.现在,它每次都会要求输入密码。
For root, I have my SSH public key in.ssh/authorized_keys.对于 root,我有我的 SSH 公钥 in.ssh/authorized_keys。 The key should also work for
git
.该密钥也应该适用于
git
。 Do I have to add another authorized_keys file for this git
user?我是否必须为此
git
用户添加另一个 authorized_keys 文件? With my useradd
command, I do not create a home directory where I could add it, so where should it go?使用我的
useradd
命令,我没有创建可以添加它的主目录,那么它应该在哪里 go?
Thank you all for your help!谢谢大家的帮助!
Run sudo tail -f /var/log/auth.log
and attempt to login once more from a different console.运行
sudo tail -f /var/log/auth.log
并尝试从不同的控制台再次登录。 You will see now the lag that should tell you why exactly the login was denied.您现在将看到应该告诉您登录被拒绝的确切原因的滞后。
In my case there were wrong permissions for the home folder.就我而言,主文件夹的权限错误。
You did create a home directory, it just isn't sitting under /home
.您确实创建了一个主目录,它只是不在
/home
下。
/srv/git
Under that directory create a .ssh
directory, fix the permissions:在该目录下创建一个
.ssh
目录,修复权限:
mkdir /srv/git/.ssh
chmod 0700 /srv/git/.ssh
Create a new authorized_keys file with the public key in it, fix the permissions:创建一个包含公钥的新 authorized_keys 文件,修复权限:
vim /srv/git/.ssh/authorized_keys # or method of your choice
chmod 0600 /srv/git/.ssh/authorized_keys
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.