From 0732fb32fec69a8c0c52988899bdd93434ad9e4a Mon Sep 17 00:00:00 2001 From: Matthias Lucas Jaros Date: Mon, 20 Oct 2025 08:26:24 +0200 Subject: Put user authorized keys into environment file --- init | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'init') diff --git a/init b/init index 44f46e3..fd081a8 100755 --- a/init +++ b/init @@ -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 [: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 :" + echo -e "\t -r, --repo \t\t Repo setting in form of :. 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 -- cgit v1.3.1