adduser username
Enter a password. (Generate a strong password like: openssl rand -base64 18
)
Add user to sudoers group: usermod -aG sudo username
Or Specifying Explicit User Privileges in /etc/sudoers
:
Run visudo
and add:
root ALL=(ALL:ALL) ALL
username ALL=(ALL:ALL) ALL
Login with your user and setup ssh key for your user.
If ssh is not installed by default:
sudo apt install openssh-server
sudo systemctl enable --now ssh
sudo systemctl status ssh
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.initial
sudo nano /etc/ssh/sshd_config
Set PubKeyAuthentication
to yes
.
sudo systemctl restart ssh
mkdir ~/.ssh
cd ~/.ssh/
touch authorized_keys
vim authorized_keys
Now add your ssh public key. Save and exit. Verify if ssh login via key is working. If yes, good to disable password now.
sudo vim /etc/ssh/sshd_config
Change:
PasswordAuthentication no
Restart ssh and good to go:
sudo systemctl restart ssh
sudo apt update
sudo apt upgrade
sudo apt install -y vim tree tmux npm git
# NodeJs
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt install build-essential
sudo apt update
Setup go:
sudo apt install golang-go
wget -O ~/.tmux.conf https://gist.githubusercontent.com/anistark/1f686bab54e93d1941f9/raw/8962c23f8d897510cce6b9f722a720d53210dcf7/tmux.conf
Setup tmux.conf
Setup bash_profile
source ~/.bashrc
source ~/.bash_profile
Setup Redis.
sudo apt install redis-server -y
sudo apt update
sudo apt install nginx
sudo ufw status
sudo systemctl enable nginx
Full Setup NGINX
Setup Postgres
sudo apt install postgresql postgresql-contrib -y
sudo -u postgres psql
Create user with password: CREATE USER ani WITH PASSWORD '123';
Refer Postgres Full Setup
Setup pm2
pm2 start -i 4 --name="appName" npm -- start
Setup forever
forever start app.js
Setup virtualenv
sudo apt update
sudo apt install python-virtualenv
Setup Certbot
sudo apt install certbot python3-certbot-nginx -y
Run Certbot (after app installation):
sudo certbot --nginx
Check certbot autorun: sudo systemctl status certbot.timer
Ref Full Setup
- In case of failed install to overwrite a debian package, you have to force overwrite the files causing issues:
sudo dpkg -i --force-overwrite <file-path>
. Then check if everything is fixed by running:sudo apt-get --fix-broken install
Usually might happen for node 18 install.sudo dpkg -i --force-overwrite /var/cache/apt/archives/nodejs_20.5.0-deb-1nodesource1_amd64.deb