Original Debian VPS setup script

version 1.0, February 2024, created with assistance from chatGPT version 3.0

#!/bin/bash

Step 1: Update .bashrc for user with aliases

cat << EOF >> /home/user/.bashrc
alias dl=‘cd ~/Downloads’
alias doc=‘cd ~/Documents’
alias egrep=‘egrep --color=auto’
alias fgrep=‘fgrep --color=auto’
alias myhome=‘cd ~’
alias grep=‘grep --color=auto’
alias apti=‘sudo apt-get -y install’
alias aptu=‘sudo apt-get update && sudo apt-get -y upgrade’
alias ll=‘ls -alFh’
alias ls=‘ls --color=auto’
alias ping=‘ping -c 6’
alias ping6=‘ping6 -c 6’
alias rsync=‘ionice -c2 -n7 rsync’

#Update the source for ‘user’

source /home/user/.bashrc

#Step 2: Update the Debian installation

#No need for update because alias for upgrade already updates the apt

sudo aptu

#Step 3: Install curl, wget, rclone, ufw, neofetch

sudo apti curl wget rclone neofetch fortune ufw

#Step 4: Configure ufw

sudo ufw default deny incoming

sudo ufw default allow outgoing

sudo ufw enable

sudo ufw allow 80/tcp,443/tcp,22,21,53/udp

#sudo ufw allow custom port (optional)

#sudo ufw allow xxxx

#Step 5 Enable UFW for IPv6 as well

sudo sed -i ‘s/IPV6=no/IPV6=yes/g’ /etc/default/ufw

sudo ufw reload

#Step 6 Update /etc/ssh/sshd_config

sudo sed -i ‘s/#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/g’ /etc/ssh/sshd_config

sudo echo ‘ClientAliveInterval 20’ >> /etc/ssh/sshd_config

sudo echo ‘ClientAliveCountMax 30’ >> /etc/ssh/sshd_config

sudo sed -i ‘s/#X11Forwarding yes/X11Forwarding no/g’ /etc/ssh/sshd_config

sudo echo ‘Port xxxx’ >> /etc/ssh/sshd_config

sudo systemctl restart sshd

## End of script
Banner image for blog post Debian VPS Setup with Shell Script. If you do not see this image, then brick.do (the original host for this post) is no longer active.
Banner image generated for a blog post when Debian 11 was launched

Note: If you do not see this image, then brick.do (the original host for this post) is no longer active.

Pages: 1 2