#!/bin/bash
sudo apt update -y && sudo apt upgrade -y
# print the current SHELL
echo -e "THE CURRENT SHELL IS ===> $SHELL"
# installing the zshell
echo INSTALLING THE ZSHELL
# installing it
sudo apt install zsh -y
# zsh --version
echo -e "THE VERSION OF THE ZSHELL IS ===> $(zsh --version)"e
# Setting the Zshell configurations
echo SETTING THE CONFIGURATIONS FOR ZSHELL
# Start the ZSHELL
zsh
# switching to ZSHELL
chsh -s $(which zsh)
echo -e "Install Oh My Zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Enable auto-suggestions
echo "Enable Auto-Suggestions & Syntax Highlighting"
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# Make sure to add them to your zshell config
If you want to remove the zsh
sudo apt --purge remove zsh
Installing Docker
sudo apt install apt-transport-https ca-certificates curl software-properties-common
# Install the GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker to APT source
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update your pakages
sudo apt update
# check if docker is in the packages
apt-cache policy docker-ce
# install docker
sudo apt install docker-ce -y
#Check docker status
sudo systemctl status docker
Remove Docker Completely
To completely remove Docker from an Ubuntu 22.04 server, you'll need to uninstall the Docker packages and also remove any Docker-related configuration files and images. Here are the steps to do this:
- Uninstall Docker packages: You should first remove the Docker packages installed on your system. You can do this with the following command:
- Remove Docker configuration files and directories: After uninstalling the packages, you should remove any Docker configuration files and directories that might be left behind. Use the following commands to remove Docker's configuration and data:
- Remove Docker images and containers: To remove Docker images and containers that are no longer needed, you can use the following commands. Be cautious with these commands, as they will permanently delete your Docker data.
- Remove Docker Compose (if installed): If you have Docker Compose installed, you can remove it using the following command:
- Clean up unused packages and dependencies: To remove any residual dependencies and packages that were automatically installed when you installed Docker, you can use the following command:
- Remove Docker-related users and groups: Docker creates some users and groups during installation. To remove these, use the following commands:
- Reboot your server: It's a good idea to reboot your server to ensure that all changes are applied and any remaining Docker-related processes are terminated.
bashCopy code
sudo apt-get purge docker-ce docker-ce-cli containerd.io
bashCopy code
sudo rm -rf /etc/docker
sudo rm -rf /var/lib/docker
bashCopy code
sudo docker rm -f $(docker ps -a -q)
sudo docker rmi -f $(docker images -q)
bashCopy code
sudo rm /usr/local/bin/docker-compose
bashCopy code
sudo apt-get autoremove
bashCopy code
sudo groupdel docker
sudo userdel docker
bashCopy code
sudo reboot
After following these steps, Docker should be completely removed from your Ubuntu 22.04 server. Make sure you have backups of any important data stored in Docker containers, as the removal process will delete all Docker-related data.
Install Fail2ban
Fail2ban is a popular open-source intrusion prevention tool for Linux systems that helps protect your server by monitoring for suspicious or repeated failed login attempts and automatically banning the IP addresses associated with those attempts. Here's how to set up Fail2ban on an Ubuntu server:
- Update your system: First, make sure your system is up to date. Open a terminal and run the following commands:
- Install Fail2ban: Install Fail2ban using the package manager:
- Configure Fail2ban:
The main configuration file for Fail2ban is located at
/etc/fail2ban/jail.local
. You should create a local configuration file if it doesn't already exist: - Edit the configuration file:
Open the
/etc/fail2ban/jail.local
file with your preferred text editor, for example: - [sshd] section: This section controls SSH protection. Make sure it's enabled (
enabled = true
) and set the maximum number of login failures before banning (maxretry
). You can also set the duration of the ban (bantime
). - [DEFAULT] section: You can set the email notifications to receive alerts for bans and unbans by configuring
destemail
. - Start and enable Fail2ban: Start the Fail2ban service and enable it to start at boot:
- Check the status: You can check the status of Fail2ban to ensure it's running without errors:
- Testing Fail2ban:
To test Fail2ban, you can use a tool like
fail2ban-client
to simulate a failed login attempt and see if an IP gets banned. For example, to simulate a failed SSH login:
sudo apt update
sudo apt upgrade
sudo apt install fail2ban
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
Here are some common settings you might want to configure in the jail.local
file:
sudo systemctl start fail2ban
sudo systemctl enable fail2ban
sudo fail2ban-client status
fail2ban-client set sshd banip 1.2.3.4
Replace 1.2.3.4
with the IP address you want to ban.
Fail2ban will automatically unban IP addresses after the bantime
specified in the configuration.
That's it! You've successfully set up Fail2ban on your Ubuntu server to protect against brute-force attacks and unauthorized access. You can further customize the configuration to suit your specific needs.
To Check if someone is banned
# make sure to replace the <sshd> with your service
sudo fail2ban-client status <sshd>
Install Podman
sudo dnf install -y podman
systemctl enable podman