SSH into your server and cd (change directory) to the folder where you have .htaccess file and execute the following command.
user@user-desktop:~$ htpasswd -c .htpasswd username New password: Re-type new password: Adding password for user username
if you open the .htpasswd file you can see something like this –
Add/modify .htaccess file:
AuthUserFile Path to your .htpasswd file ex: /var/www/mydrupal/.htpasswd AuthType Basic AuthName "Restricted Access" Require user username