Skip to content

Instantly share code, notes, and snippets.

@imneonizer
Last active March 3, 2026 17:46
Show Gist options
  • Select an option

  • Save imneonizer/c7ec701f0f50e51d195a20bf4fa7fde9 to your computer and use it in GitHub Desktop.

Select an option

Save imneonizer/c7ec701f0f50e51d195a20bf4fa7fde9 to your computer and use it in GitHub Desktop.
cat ~/.netrc
machine github.com login <login-id> password <token-password>
#!/bin/bash
set -e
echo "Disabling UFW if installed..."
if command -v ufw >/dev/null 2>&1; then
sudo ufw disable || true
fi
echo "Flushing all iptables rules..."
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
echo "Setting default policies to ACCEPT..."
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
echo "Installing iptables-persistent..."
sudo apt update -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y iptables-persistent
echo "Saving clean firewall state..."
sudo netfilter-persistent save
echo "Firewall fully reset. All ports now controlled only by Oracle Cloud."
#!/bin/bash
# the script is tested on ubuntu 20.04
# ==== automatically call script with sudo ====
if [ `whoami` != root ]; then sudo -E $0 $@; exit; fi
# change default password
username=`logname`
new_password="root"
echo $username:$new_password | chpasswd
# enable ssh password authentication
sed -i "/PasswordAuthentication no/c\\PasswordAuthentication yes" /etc/ssh/sshd_config
service sshd restart
# install docker
apt install -y docker.io
chmod 666 /var/run/docker.sock
# install utility tools
apt install -y net-tools python3-pip tmux
# add swap memory
fallocate -l 8G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon --show
# make swapfile permanent by adding entry to fstab file
! grep -q /swapfile /etc/fstab && echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
# add user alias
! grep -q python=python3 /home/`logname`/.bashrc && echo "alias python=python3" >> /home/`logname`/.bashrc
! grep -q pip=pip3 /home/`logname`/.bashrc && echo "alias pip=pip3" >> /home/`logname`/.bashrc
# install teme for login alerts
pip3 install teme
TEXT="$(date): ssh login to ${USER}@$(hostname)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
curl -s -X POST "https://api.telegram.org/bot<token>/sendMessage" -d "chat_id=<chatid>" -d "text=${TEXT}" -d "disable_web_page_preview=true" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment