Skip to content

Instantly share code, notes, and snippets.

@imneonizer
Last active April 15, 2022 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imneonizer/c7ec701f0f50e51d195a20bf4fa7fde9 to your computer and use it in GitHub Desktop.
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
# 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
#!/bin/bash
#/etc/ssh/sshrc
# alert when someone connect via ssh
TEXT="$(date): ssh login to ${USER}@$(hostname)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
python3 -m teme -m "$TEXT" &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment