diff options
| author | 2025-10-20 08:26:24 +0200 | |
|---|---|---|
| committer | 2025-10-20 08:31:03 +0200 | |
| commit | 0732fb32fec69a8c0c52988899bdd93434ad9e4a (patch) | |
| tree | 1ce663325e502ad654090b7e2e6c6fb45d36f94b /init | |
| parent | 5313e8162d4cdd6a3b9ef955f3eb09b77f2e9437 (diff) | |
Put user authorized keys into environment file
Diffstat (limited to 'init')
| -rwxr-xr-x | init | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -10,7 +10,9 @@ set _REPO_PERMISSIONS /etc/repo-permissions set _REPO_REGEX "^((?:\/[a-zA-Z-]+)+.git)\$" function createUser - set -l user $argv[1] + set -l userConfig (string split ':' $argv[1]) + set -l user $userConfig[1] + set -l key $userConfig[2] echo "Setting up user: $user" if [ "$user" = git ] echo "Error: User git is reserved" @@ -24,7 +26,7 @@ function createUser # unlock account to allow ssh logins passwd -u "$user" mkdir "$HOME/.ssh" - cp "/var/ssh/clients/$user" "$HOME/.ssh/authorized_keys" + echo "$key" > "$HOME/.ssh/authorized_keys" chown -R $user "$HOME" chmod -R 700 "$HOME" end @@ -74,9 +76,9 @@ if set -q _flag_h echo -e "" echo -e "OPTIONS" echo -e "\t -h, --help \t\t Display this page" - echo -e "\t -g, --git-uid \t UID of the git user that is used also as ownership for all repos" - echo -e "\t -u, --user \t\t Setting up a user" - echo -e "\t -r, --repo \t\t Setting up a repo in form <repo-path>[:user1]+ for each user who should have access to it" + echo -e "\t -g, --git-uid \t\t UID of the git user that is used also as ownership for all repos" + echo -e "\t -u, --user \t\t User setting in form of <user-name>:<public-key>" + echo -e "\t -r, --repo \t\t Repo setting in form of <repo-path>:<allowed-user1>. You can add as many users as you want. Currently if a user is allowed he has all permissions read/write" echo -e "" return end @@ -97,9 +99,11 @@ if set -q $_flag_g end # Setup users +# git user has read/write access to all repos, set git-shell +# and no password login allowed -> no ssh login possible adduser git -u $GIT_UID -D --shell "/usr/bin/git-shell" -for user in $users - createUser "$user" +for userConfig in $users + createUser "$userConfig" end # Setup repos |
