authorized_keys ignored for new git user

347 views Asked by At

I want to create an own git server. I started with a root user and here is the following I did:

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).

I want to login via [email protected] without the use of a password. Right now, it will ask for a password every time.

For root, I have my SSH public key in .ssh/authorized_keys. The key should also work for git. Do I have to add another authorized_keys file for this git user? With my useradd command, I do not create a home directory where I could add it, so where should it go?

Thank you all for your help!

2

There are 2 answers

0
Adam Ryczkowski On

Run sudo tail -f /var/log/auth.log and attempt to login once more from a different console. 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.

0
tink On

You did create a home directory, it just isn't sitting under /home.

/srv/git

Under that directory create a .ssh directory, fix the permissions:

  • mkdir /srv/git/.ssh
  • chmod 0700 /srv/git/.ssh

Create a new authorized_keys file with the public key in it, fix the permissions:

  • vim /srv/git/.ssh/authorized_keys # or method of your choice
  • chmod 0600 /srv/git/.ssh/authorized_keys