# Ubuntu Setup 20.04 LTS

# Tutorial

  1. Setup ssh config with .pem file from AWS Instance.
  2. file permission chmod 600 on pem.
  3. ssh as ubuntu user (default)
  4. sudo su to change to root user.
  5. Create new user with sudo privileges.
  6. Create a .ssh directory in the home diretory of the new user. If you have issues user chmod 700 .ssh directory to close it to public access.
    1. add authorized_keys file to the .ssh directory.
    2. Copy in rsa-id key into the file ( can use the default one from ubuntu user)
  7. change back to root user ( leave window open do not exit )
  8. try to ssh in as new user.
  9. Once successful disable login password for ubuntu user by expiring the password with sudo usermod --expiredate 1 ubuntu
    1. re-enable with sudo usermod --expiredate "" ubuntu.
  10. Setup UFW firewall
  11. Ensure OpenSSH is allowed!
    1. Do not logout before ensuring OpenSSH is enabled and UFW is on.

# References

Ubuntu 18.04 Tutorial(opens new window)

Chmod 700 .ssh directory(opens new window)

Open SSH Keys Ubuntu(opens new window)

SSH-key RSA Gen(opens new window)

Common Questions(opens new window)

# Flask Setup

# Tutorial

Notes

  • ufw allow OpenSSH
  • create non-root user, if using same .pem key. copy authorized_key from ubunutu home directory to new user directory under .ssh
  • ssh into instance with new user
  • Assign Elastic IP address to ec2 instance
  • Login into AWS Route 53 and create a new A record for domain. i.e,. Megatron.kpfui.dev and set target to elastic IP address (AKA public ip address).
  • Once you obtain SSL certs run sudo ufw status and remove Nginx HTTP and add Nginx Full.

# Updating

Uwsgi server is setup to update when scout.py is changed and will perform a graceful reload. Must install dependencies manually on server under the scout_env virtual enviornment.

Currenty installed

  • Pandas
  • Numpy

# References

Ubuntu + Nginx + Flask(opens new window)

# Node Setup

# Tutorial

  • Follow basic setup for Nginx on Ubuntu
  • Make sure to enable Nginx Full for http and https traffic.

# PM2

The server is constructed by the ecosystem.config.js file. The file contains environmental authentication variables.

Useful Commands

pm2 logs shows real-time logs pm2 status shows status of cluster nodes pm2 restart ecosystem.config.js restarts the cluster with settings from the ecosystem config file. pm2 momnit GUI of cluster information

# References

PM2 Ecosystem Config(opens new window) Basic Setup(opens new window)

# MongoDB

Ubuntu 20.04 + MongoDB(opens new window)

TIP

Set Firewall to home + app IP address and comment out bindIP option in /etc/mongo.conf.