How to identify a user who has connected via ssh?

You need to restrict push to certain branches. To do this in hook Gita need to determine which user was connected. All connected via the same user using ssh keys. To determine the user needs to obtain his public key, to it user and save in a variable environment. The mechanism is clear, I do not understand how to sshrc's to get the public key for the current connection, man read, but not found.
upd
Found this option, but couldn't convert. Have read man sshd, authorized_keys to have the opportunity to add environment settings using environment="NAME=value", which is basically me, but the problem is not being able to run, if you write after the public key, the variable is not set if before, then the authorization key occurs.
these are the options I used:
environment="GIT_USER=deployer" ssh-rsa AAAA....... user@computer
ssh-rsa AAAA....... user@computer environment="GIT_USER=deployer"
July 9th 19 at 11:12
1 answer
July 9th 19 at 11:14
Wouldn't it be easier to go the conventional way to use multiple users in Git?
It would be an extreme case, if you can't find a solution with a single user. one user is easier, all the authorized keys is stored in one file. - daniella.Murray commented on July 9th 19 at 11:17
:
VI?

Why administer custom keys yourself?

For example, we have the users themselves create the keys, entering the Networks on their individual password. - Weston98 commented on July 9th 19 at 11:20
: we have deployed a pure git - daniella.Murray commented on July 9th 19 at 11:23
: I do not believe that there is no "just users". - Weston98 commented on July 9th 19 at 11:26
: git is not engaged in the distribution of rights by user, it is not his job - daniella.Murray commented on July 9th 19 at 11:29
: he was not. it has add-ons.
gitolite - under your task goes better, IMHO.
gitosis
etc.
IMHO, you're naked on the bare git trying to define complex policies. - Weston98 commented on July 9th 19 at 11:32
: for gitolite thank you for reading about him at your leisure - daniella.Murray commented on July 9th 19 at 11:35

Find more questions by tags GitSSH