- List keys
ls -l ~/.ssh/id_*.pub - Generate key
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_sohoj_rsa -C "[email protected]" - To copy ssh key to server
sudo ssh-copy-id -i ~/.ssh/id_sohoj_rsa user@host - Login using
sudo ssh -i ~/.ssh/id_sohoj_rsa user@host - Change ssh auth ways
sudo nano /etc/ssh/sshd_config - Change those
PasswordAuthentication no ChallengeResponseAuthentication no UsePAM no - Restart using
sudo systemctl restart ssh - Add new user
adduser sammy - Give privileges
usermod -aG sudo sammy - Basic firewall setup
ufw app list,ufw allow OpenSSH,ufw enable,ufw status - Copy ssh keys from root to sammy
rsync --archive --chown=sammy:sammy ~/.ssh /home/sammy - Login using
sudo ssh -i ~/.ssh/id_rsa sammy@host - Nginx
sudo apt update,sudo apt install nginx - Adjust firewall
sudo ufw app list,sudo ufw allow 'Nginx HTTP',sudo ufw status,systemctl status nginx - Some nginx commands
sudo systemctl stop nginx,sudo systemctl start nginx,sudo systemctl restart nginx,sudo systemctl reload nginx,sudo systemctl disable nginx,sudo systemctl enable nginx - Nginx conf change
sudo nano /etc/nginx/nginx.conf,server_names_hash_bucket_size 64;,sudo nginx -t,sudo systemctl restart nginx - Lets encrypt
sudo add-apt-repository ppa:certbot/certbot,sudo apt install python-certbot-nginx - Add domain
sudo nano /etc/nginx/sites-available/default - Change
server_name example.com www.example.com;,sudo nginx -t,sudo systemctl reload nginx - Allowing https
sudo ufw status,sudo ufw allow 'Nginx Full',sudo ufw delete allow 'Nginx HTTP',sudo ufw status - Obtain SSL certificate
sudo certbot --nginx -d example.com -d www.example.com - Auto renewal
sudo certbot renew --dry-run - Install Nodejs
sudo apt-get install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -,sudo apt-get install nodejs,node -v,npm -v - Pm2 install
sudo npm install pm2@latest -g,pm2 startup systemd,pm2 start hello.js,pm2 stop hello.js - Pm2 startup
pm2 startup systemd,sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u sammy --hp /home/sammy,pm2 save,pm2 list,pm2 info app_name,pm2 monit,pm2 start npm --no-automation --name {app name} -- run {script name} - Server setup
sudo nano /etc/nginx/sites-available/default,location / { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; },sudo nginx -t,sudo systemctl restart nginx - Mongo
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -,echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list,sudo apt-get install -y mongodb-org=4.2.1 mongodb-org-server=4.2.1 mongodb-org-shell=4.2.1 mongodb-org-mongos=4.2.1 mongodb-org-tools=4.2.1 - Mongo commands
sudo service mongod start,sudo service mongod stop,sudo service mongod restart,mongo,sudo systemctl status mongod - Mongodb systemctl commands
sudo systemctl status mongodb,sudo systemctl stop mongodb,sudo systemctl start mongodb,sudo systemctl restart mongodb,sudo systemctl disable mongodb,sudo systemctl enable mongodb - Secure mongo
use admin,db.createUser( { user: "AdminOce", pwd: "PWD2018AdminOce", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ),sudo nano /etc/mongod.conf,security: authorization: "enabled",sudo systemctl restart mongod,sudo systemctl status mongod,sudo systemctl enable mongod - Check auth
mongo,show dbs,mongo -u AdminOce -p --authenticationDatabase admin,show dbs - Needed step for admin user
use admin; db.grantRolesToUser('admin', [{ role: 'root', db: 'admin' }]) - Check Link
https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac - Node js env set
sudo nano ~/.bash_profile,export DATABASE_USERNAME="" export DATABASE_PASSWORD="" export DATABASE_NAME="strapi" export DATABASE_PORT=27017 export DATABASE_HOST="127.0.0.1",source ~/.bash_profile - Strapi
npm i -g strapi@latest
Last active
September 6, 2021 02:24
-
-
Save asif633/e0f8e47fd7d0e6e09bdf1420aa396aeb to your computer and use it in GitHub Desktop.
Author
Author
sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kill port sudo kill -9
sudo lsof -t -i:9001