cat ~/.netrc
machine github.com login <login-id> password <token-password>
Last active
June 30, 2024 00:54
-
-
Save imneonizer/c7ec701f0f50e51d195a20bf4fa7fde9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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