Protect wp-admin with htaccess

= Create .htpasswd file:

sudo htpasswd -c /path/to/.htpasswd john

Then you’ll be asked to type password you wish to use

= Create .htaccess file into wp-admin folder

AuthType Basic
AuthName "Restricted Content"
AuthUserFile /path/to/.htpasswd
Require valid-user
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>