INeedHelp
This commit is contained in:
parent
bbf36c683a
commit
0de30b2c32
127
consulting/INeedHelp.sh
Normal file
127
consulting/INeedHelp.sh
Normal file
|
@ -0,0 +1,127 @@
|
|||
#!/bin/bash
|
||||
|
||||
# ASCII Art
|
||||
echo "
|
||||
###### ######
|
||||
# # # # # ###### # # # # ##### #### ######
|
||||
# # # # # # # # # # # # # # #
|
||||
###### # ## ##### # ###### # # # # #####
|
||||
# # ## # # # # # # # # ### #
|
||||
# # # # # # # # # # # # # #
|
||||
# # # # ###### ###### # # # ##### #### ######
|
||||
"
|
||||
|
||||
echo "Vetheon is coming to help!"
|
||||
|
||||
# Function to install packages
|
||||
install_packages() {
|
||||
local packages=("$@")
|
||||
for package in "${packages[@]}"; do
|
||||
if ! command -v "$package" >/dev/null 2>&1; then
|
||||
echo "Installing $package..."
|
||||
if command -v apt-get >/dev/null; then
|
||||
apt-get install -y "$package"
|
||||
elif command -v dnf >/dev/null; then
|
||||
dnf install -y "$package"
|
||||
elif command -v yum >/dev/null; then
|
||||
yum install -y "$package"
|
||||
elif command -v pacman >/dev/null; then
|
||||
if ! pacman -Q "$package" >/dev/null 2>&1; then
|
||||
pacman -Sy --noconfirm "$package"
|
||||
fi
|
||||
elif command -v apk >/dev/null; then
|
||||
apk add "$package"
|
||||
else
|
||||
echo "Unsupported package manager. Please install $package manually."
|
||||
fi
|
||||
else
|
||||
echo "$package is already installed."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Detect package manager and install required packages
|
||||
if command -v apt-get >/dev/null; then
|
||||
apt-get update
|
||||
install_packages kitty sudo wget sendmail
|
||||
elif command -v dnf >/dev/null; then
|
||||
install_packages kitty sudo wget sendmail
|
||||
elif command -v yum >/dev/null; then
|
||||
install_packages kitty sudo wget sendmail
|
||||
elif command -v pacman >/dev/null; then
|
||||
install_packages kitty sudo wget
|
||||
if ! command -v sendmail >/dev/null; then
|
||||
if ! command -v yay >/dev/null; then
|
||||
echo "Installing yay..."
|
||||
cd /opt || exit
|
||||
sudo git clone https://aur.archlinux.org/yay.git
|
||||
sudo chown -R "$(whoami)" ./yay
|
||||
cd yay || exit
|
||||
makepkg -si --noconfirm
|
||||
fi
|
||||
yay -S --noconfirm sendmail
|
||||
fi
|
||||
elif command -v apk >/dev/null; then
|
||||
apk update
|
||||
install_packages kitty sudo wget sendmail
|
||||
else
|
||||
echo "Unsupported package manager. Please install kiTTY, sudo, wget, and sendmail manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create user 'vetheon' and set password
|
||||
if ! id -u vetheon >/dev/null 2>&1; then
|
||||
useradd -m -s /bin/bash vetheon
|
||||
echo "vetheon:Changeme123" | chpasswd
|
||||
usermod -aG sudo vetheon
|
||||
mkdir -p /home/vetheon/.ssh
|
||||
wget -O /home/vetheon/.ssh/authorized_keys https://keys.pixelridgesoftworks.com/vetheon_ssh_key.pub
|
||||
chown -R vetheon:vetheon /home/vetheon/.ssh
|
||||
chmod 600 /home/vetheon/.ssh/authorized_keys
|
||||
echo "User 'vetheon' created and SSH key added."
|
||||
else
|
||||
echo "User 'vetheon' already exists."
|
||||
fi
|
||||
|
||||
# Restart sshd
|
||||
if systemctl is-active --quiet sshd; then
|
||||
systemctl restart sshd
|
||||
elif systemctl is-active --quiet ssh; then
|
||||
systemctl restart ssh
|
||||
else
|
||||
service ssh restart
|
||||
fi
|
||||
|
||||
# Send email notification
|
||||
IP=$(hostname -I | awk '{print $1}')
|
||||
EMAIL_SUBJECT="New User Setup"
|
||||
EMAIL_BODY="A new user 'vetheon' has been setup on the server with IP: $IP"
|
||||
echo -e "Subject: $EMAIL_SUBJECT\n\n$EMAIL_BODY" | sendmail -f no-reply@pixelridgesoftworks.com -S mail.pixelridgesoftworks.com:587 -xu no-reply@pixelridgesoftworks.com -xp '%,25,UmbRih' connor@pixelridgesoftworks.com
|
||||
|
||||
# Create removal script
|
||||
cat << 'EOF' > /usr/local/bin/remove_vetheon.sh
|
||||
#!/bin/bash
|
||||
|
||||
# Remove user 'vetheon'
|
||||
userdel -r vetheon
|
||||
|
||||
# Remove SSH key
|
||||
rm -f /home/vetheon/.ssh/authorized_keys
|
||||
|
||||
# Restart sshd
|
||||
if systemctl is-active --quiet sshd; then
|
||||
systemctl restart sshd
|
||||
elif systemctl is-active --quiet ssh; then
|
||||
systemctl restart ssh
|
||||
else
|
||||
service ssh restart
|
||||
fi
|
||||
|
||||
echo "User 'vetheon' has been removed from the system."
|
||||
EOF
|
||||
|
||||
chmod +x /usr/local/bin/remove_vetheon.sh
|
||||
|
||||
# Final message
|
||||
echo "You have just given an employee of PixelRidge Softworks access to your machine."
|
||||
echo "To remove this access, run 'sudo /usr/local/bin/remove_vetheon.sh'."
|
Loading…
Reference in New Issue
Block a user