This just simply outputs what you need a username and password that can be used to authenticate from .htaccess
htpasswd -nb user password
If you want to write it straight to a file
htpasswd -cb /tmp/somefile.pw user password
How To Use This In .htaccess
This can be very tricky, say you are doing development on a file that is symlinked. Doing a "cp dev.file dev.file-bk" won't do what you expect, it just links back to the same file so you haven't copied or backed anything up.
You need the "-H" switch to copy the actual file that is referenced by the symlink:
cp -Hdev.file dev.file-bk........