New

1. Add the username:

sudo sh -c "echo -n 'myusername:' >> /etc/nginx/.htpasswd"


2. Then add the encrypted password:

sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"

Check the resulting file:

cat /etc/nginx/.htpasswd


myusername:$apr1$wI1/T0nB$jEKuTJHkTOOWkopnXqC1d1