title: Encrypted password in Berkeley DB for vsftpd using pam_userdb.so
body: <p>I am trying to install a vsftpd with some virtual users using the Berkeley DB. I have mainly followed this guide: <a href="http://www.neant.ro/2012/04/secure-ftp-with-vsftpd/" rel="nofollow">http://www.neant.ro/2012/04/secure-ftp-with-vsftpd/</a> . Everything works fine, but I want to have the passwords hashed inside the database. I am using CentOS 6.3 with glibc 2.12. </p>
  
  <p>From the manpage of pam_userdb.so I assume that I can use what crypt provides. If we take a look of crypt(3) manpage we can use SHA-256 and SHA-512. I would to use one of those.</p>
  
  <p>My doubt is how to implement it. From what I know i need to go to my pam.d file and edit and add the argument crypt but... which value should I give it? 5 for SHA-256? 6 for SHA-512?</p>
  
  <pre><code>auth    sufficient pam_userdb.so db=/path/to/db/virtual-users crypt=?
  account sufficient pam_userdb.so db=/path/to/db/virtual-users crypt=?
  session sufficient pam_loginuid.so
  </code></pre>
  
  <p>Now I need the password in SHA-256/SHA-512 inside the database. Which is the correct way to get the hash? I suppose I have to use the crypt function. However, I need to get it using Ruby, is there any way?</p>
  
  <p>Thanks in advance for the help,</p>