Answer the question
In order to leave comments, you need to log in
How to determine the user connected via ssh?
It is necessary to limit the push to certain branches. To do this, in the hook of the git, you need to determine which user has connected. All connect through the same user using ssh keys. To determine the user, you need to get his public key, get the user from it and save it to an environment variable. The mechanism itself is clear, I don’t understand how to get the public key for the current connection in sshrc, I read the man, but I didn’t find it.
upd
Found such an option, but could not implement it. I read man sshd, it is possible to add environment parameters to authorized_keys via environment="NAME=value", this basically suits me, but the problem is that I could not start it, if I write after the public key, then the variable is not set if before , then authorization by key does not occur.
Here are the options I used:
environment="GIT_USER=deployer" ssh-rsa AAAA....... [email protected]
ssh-rsa AAAA....... [email protected] environment="GIT_USER=deployer"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question