mirror of
https://github.com/elAgala/server-initializer.git
synced 2026-02-14 05:06:18 +00:00
Fixes
- Fix prometheus files path - Fix sciprt allowing to execute w/out username param - Add oh-my-zsh installation - Fix typo un ssh authorized_keys file - Fix PermitRootLogin disabling
This commit is contained in:
14
README.md
14
README.md
@@ -1 +1,15 @@
|
||||
# server-initializer
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/elAgala/server-initializer/main/index.sh
|
||||
chmod +x index.sh
|
||||
./index.sh <username>
|
||||
```
|
||||
|
||||
## Included
|
||||
- Server update
|
||||
- User creation
|
||||
- SSH key configuration (AllowUser, disable root login)
|
||||
-
|
||||
|
||||
5
index.sh
5
index.sh
@@ -3,6 +3,11 @@
|
||||
REPO_URL="https://github.com/elAgala/server-initializer"
|
||||
TARGET_DIR="/tmp/server-initializer"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "[ ERROR ]: No username provided. Use ./index.sh <username>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "Cloning the repository..."
|
||||
git clone "$REPO_URL" "$TARGET_DIR"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
function install_prometehus() {
|
||||
REPO_URL="https://raw.githubusercontent.com/elAgala/monitoring-template/main"
|
||||
REPO_URL="https://raw.githubusercontent.com/elAgala/monitoring-template/master"
|
||||
username="$1"
|
||||
monitoring_dir="/home/$username/monitoring"
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ function config_ssh() {
|
||||
sudo mkdir -p $ssh_dir
|
||||
sudo chmod 700 $ssh_dir
|
||||
|
||||
sudo touch "$ssh_dir/authorized_leys"
|
||||
sudo chmod 600 "$ssh_dir/authorized_leys"
|
||||
sudo touch "$ssh_dir/authorized_keys"
|
||||
sudo chmod 600 "$ssh_dir/authorized_keys"
|
||||
sudo chown -R "$username:$username" $ssh_dir
|
||||
echo "[ SSH ]: Created ~/.ssh/authorized_leys"
|
||||
echo "[ SSH ]: Created ~/.ssh/authorized_keys"
|
||||
|
||||
echo "[ SSH ]: Paste the public key for $username (leave empty to skip)"
|
||||
read -r public_key
|
||||
@@ -24,7 +24,7 @@ function config_ssh() {
|
||||
fi
|
||||
|
||||
echo "[ SSH ]: Disabling root login"
|
||||
sudo sed -i 's/^#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
|
||||
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
|
||||
echo "[ SSH ]: Root login disabled"
|
||||
|
||||
echo "[ SSH ]: Adding $username to allowed users"
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
function install_zsh() {
|
||||
username=$1
|
||||
echo "[ UTILS ]: Installing zsh"
|
||||
|
||||
echo "[ UTILS ]: Installing Zsh"
|
||||
sudo apt-get install -y zsh
|
||||
# Set Zsh as the default shell for the user
|
||||
sudo chsh -s /usr/bin/zsh "$username"
|
||||
echo "[ UTILS ]: Zsh installed succesfully and set as default shell for $username"
|
||||
echo "[ UTILS ]: Installing Oh My Zsh for $username"
|
||||
# Install Oh My Zsh
|
||||
sudo -u "$username" sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
|
||||
echo "[ UTILS ]: Zsh and Oh My Zsh installed successfully and set as the default shell for $username"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ function setup_ufw() {
|
||||
echo "[ WEB ]: Started UFW Firewall setup"
|
||||
sudo apt-get install -y ufw
|
||||
sudo ufw allow 22
|
||||
sudo ufw allow 80
|
||||
sudo ufw allow 443
|
||||
sudo ufw enable
|
||||
echo "[ WEB ]: UFW Installed succesfully. Open ports SSH:22 - HTTPS:443"
|
||||
echo "[ WEB ]: UFW Installed succesfully. Open ports SSH:22 - HTTPS:443 - HTTP:80"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user