- Create droplet with Ubuntu 24.04
ssh root@[DROPLET IP ADDRESS]
- Get password from your email
- Change password on first login
adduser deployer
- Enter password and other information
usermod -aG sudo deployer
- In your local machine,
ssh-keygen
- Generate a key, if you leave passphrase blank, no need for password
ls ~/.ssh
to show files in local machine- Get the public key,
cat ~/.ssh/id_rsa.pub
- Copy it
cd ~/.ssh
andvim authorized_keys
- Paste key
- Repeat steps for deployer user
su deployer
thenmkdir ~/.ssh
fix permissionschmod 700 ~/.ssh
vim ~/.ssh/authorized_keys
and paste keychmod 600 ~/.ssh/authorized_keys
to restrict this from being modifiedexit
to return to root user
sudo vim /etc/ssh/sshd_config
- Find PasswordAuthentication and set that to
no
- Turn on
PubkeyAuthentication yes
- Turn off
ChallengeResponseAuthentication no
- Reload the SSH service
sudo systemctl reload ssh
- Test new user in a new tab to prevent getting locked out
- View all available firewall settings
sudo ufw app list
- Allow on OpenSSH so we don't get locked out
sudo ufw allow OpenSSH
- Enable Firewall
sudo ufw enable
- Check the status
sudo ufw status
sudo apt update
enter root passwordsudo apt install nginx
enter Y to installsudo ufw app list
For firewallsudo ufw allow 'Nginx HTTP'
to add NGINXsudo ufw status
to verify change- Visit server in browser
sudo apt install mysql-server
enter Y to installsudo mysql_secure_installation
to run automated securing script- Press N for VALIDATE PASSWORD plugin
- Set root password
- Remove anonymous users?
Y
- Disallow root login remotely?
N
- Remove test database and access to it?
Y
- Reload privilege tables now?
Y
sudo mysql
to enter MySQL CLISELECT user,authentication_string,plugin,host FROM mysql.user;
to verify root user's auth methodALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'STRONG_PASSWORD_HERE';
to set a root passwordSELECT user,authentication_string,plugin,host FROM mysql.user;
to verify root user's auth methodFLUSH PRIVILEGES;
to apply all changesmysql -u root -p
to access db from now on, enter passwordSTRONG_PASSWORD_HERE