Добавлен скрипт для упрощения настройки ssh + точечная актуализация
This commit is contained in:
48
gitea/config-gitea-ssh.sh
Executable file
48
gitea/config-gitea-ssh.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
echo "Configuring user 'git'..."
|
||||
|
||||
if ! id git; then
|
||||
sudo adduser \
|
||||
--system \
|
||||
--disabled-password \
|
||||
--group \
|
||||
--gecos 'Gitea user' \
|
||||
--home /home/git \
|
||||
git
|
||||
fi
|
||||
|
||||
sudo passwd -d git
|
||||
sudo usermod -aG docker git
|
||||
|
||||
currentdir=$(dirname $(readlink -e -- "${BASH_SOURCE}"))
|
||||
sudo cp -f "$currentdir/gitea-shell" /home/git/
|
||||
sudo chmod a+x /home/git/gitea-shell
|
||||
sudo usermod -s /home/git/gitea-shell git
|
||||
|
||||
sudo mkdir -p /home/git/.ssh
|
||||
sudo chown -R git:git /home/git
|
||||
sudo chmod 755 /home/git
|
||||
sudo chmod 700 /home/git/.ssh
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
cfgpath="/etc/ssh/sshd_config.d/gitea.conf"
|
||||
echo "Installing new ssh config: $cfgpath"
|
||||
sudo tee "$cfgpath" > /dev/null <<EOF
|
||||
Match User git
|
||||
PasswordAuthentication no
|
||||
AuthorizedKeysCommandUser git
|
||||
AuthorizedKeysCommand /usr/bin/docker exec -i gitea /usr/local/bin/gitea keys -e git -u %u -t %t -k %k
|
||||
EOF
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
echo "Reloading ssh configs..."
|
||||
sudo systemctl reload ssh
|
||||
# sudo systemctl reload sshd
|
||||
|
||||
echo "Done!"
|
||||
Reference in New Issue
Block a user