Linux Server Configuration for Flask Application on Amazon Lightsail
MIT
Linux Server Configuration for Flask Application on Amazon Lightsail
Amazon Lightsail
Create an Ubuntu 18 LTS instance in Lightsail.
Create a static IP address and attach it to your instance.
Enable HTTPS (port 443) on Lightsail firewall.
SSH configuration
Download your SSH key from Lightsail.
If you are using Windows Subsystem for Linux:
# navigate to the directory that contains the keycd /mnt/d/ssh
# copy the key to the ssh folder in the subsystem
cp LightSailDefaultPrivateKey-us-east-2.pem ~/.ssh/key.pem
# set permissions on the key
chmod 400 key.pem
SSH into the server, e.g:
# example
ssh -i ~/.ssh/key.pem ubuntu@11.111.11.11
Secure the server
Disallow root login and password logins:
# edit the configuration file
sudo nano /etc/ssh/sshd_config
# set these lines, if not already set
PermitRootLogin no
PasswordAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
# restart the service
sudo service ssh restart