0

I have 3 public ssh keys that correspond to 3 users that work on my server. I need to use those 3 public keys for the git user on my server, so that they can access git repositories on the server.

I ran the following in an attempt to make the git user accessible via ssh:

 cat /home/user_one/.ssh/authorized_keys >> /var/git/.ssh/authorized_keys
 cat /home/user_two/.ssh/authorized_keys >> /var/git/.ssh/authorized_keys
 cat /home/user_three/.ssh/authorized_keys >> /var/git/.ssh/authorized_keys

However, we get a git@domain.com: Permission denied (publickey) error when trying to ssh in as the git user, or trying to push to a git repository.

Notes: /var/git is the home directory of the git user. The server is on Debian 11.

We can connect to each of the users individually, why can't we connect to the git user?

2
  • @SottoVoce Looks like it was a permissions issue, the .ssh dir was 755, changed it to 700 and the home directory /var/git needed to be changed to 755 from 775, these together seemed to have solved it. Aug 10, 2022 at 21:39
  • @RawleyFowler okay, good. I'll convert my comment into an answer
    – Sotto Voce
    Aug 10, 2022 at 21:52

1 Answer 1

0

The sshd logfile on the git machine will likely tell you what it's finding wrong with the permissions on the authorized_keys file. I have a 3-point checklist I follow after I've appended to a user's authorized keys file like you describe:

  1. Make sure the git user's home dir is not writable by the world or group. This usually means 755, or 751, or 711 permissions on the home dir.
  2. Make sure the git user's .ssh dir is very locked down. Usually 700 permissions.
  3. Make sure the git user's authorized_keys file is not readable or writable by anyone but the user. Usually 600 permissions and owned by the user and the user's primary group.
1
  • authorized_keys is allowed to be world readable; similarly .ssh can be readable. The important part is that only the target user (or root) can modify the file. Typically that also means the file needs to be owned by the target user (or root). Aug 11, 2022 at 1:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .