0233.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Create a Secure Web Based Password Vault with Keepass Web</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Browser Based,Home Lab,Home Lab Ideas,Install Guide,Self-Hosted,Web Based,Web Based Tools,Debian,Homelab,How To Self-Host Keepass Web,Linux,Password Locker,Password Manager,Password Tracking,Password Vault,Security,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Create a Secure Web Based Password Vault with Keepass Web">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="12/10/2023 10:09:10 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Create a Secure Web Based Password Vault with Keepass Web</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <ol>
  26. <li>Log into the Debian device</li>
  27. <li>Run the following commands in a terminal:
  28. <div class="codeBlock"># update repositories and install any available software updates<br />
  29. sudo apt&nbsp;update<br />
  30. sudo apt&nbsp;upgrade<br />
  31. # install apache2<br />
  32. sudo apt install apache2<br />
  33. # download and extract keepass web<br />
  34. wget https://github.com/keeweb/keeweb/archive/gh-pages.zip<br />
  35. sudo unzip gh-pages.zip -d /var/www/html/<br />
  36. sudo mv /var/www/html/keeweb-gh-pages /var/www/html/keepass<br />
  37. # create webdav directory and set permissions<br />
  38. sudo mkdir /var/www/html/webdav<br />
  39. sudo chown -R www-data:www-data /var/www/html/webdav<br />
  40. # change permissions on the newly setup application folder<br />
  41. sudo chown -R www-data:www-data /var/www/html/keepass<br />
  42. # create a new keepass.conf file to configure the site<br />
  43. sudo nano /etc/apache2/sites-available/keepass.conf</div>
  44. </li>
  45. <li>Paste the following directives into keepass.conf
  46. <p>DavLockDB &quot;/var/www/html/webdav/DavLock&quot;<br />
  47. &nbsp; &lt;Location /keepass &gt;<br />
  48. &nbsp; RewriteEngine on<br />
  49. &nbsp; RewriteCond %{REQUEST_METHOD} OPTIONS<br />
  50. &nbsp; RewriteRule ^(.*)$ blank.html [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]<br />
  51. &nbsp; # Don&#39;t require LDAP authentication for a healthcheck<br />
  52. &nbsp; SetEnvIf Request_URI &quot;^/healhcheck&quot; accessgranted=1<br />
  53. &nbsp; &nbsp; Order deny,allow<br />
  54. &nbsp; &nbsp; Satisfy any<br />
  55. &nbsp; &nbsp; Deny from all<br />
  56. &nbsp; &nbsp; Allow from env=accessgranted<br />
  57. &nbsp; &nbsp; AuthType Basic<br />
  58. &nbsp; &nbsp; AuthBasicProvider ldap<br />
  59. &nbsp; &nbsp; AuthLDAPURL &quot;ldap://i12bretro.local:389/DC=i12bretro,DC=local?sAMAccountName?sub?(objectClass=user)&quot; NONE<br />
  60. &nbsp; &nbsp; AuthLDAPBindDN &quot;readonly_svc@i12bretro.local&quot;<br />
  61. &nbsp; &nbsp; AuthLDAPBindPassword &quot;Read0nly!!&quot;<br />
  62. &nbsp; &nbsp; AuthName &quot;Restricted Area [i12bretro.local]&quot;<br />
  63. &nbsp; &nbsp; # to authenticate a domain group, specify the full DN<br />
  64. &nbsp; &nbsp; AuthLDAPGroupAttributeIsDN on<br />
  65. &nbsp; &nbsp; require ldap-group CN=WebAuthAccess,CN=Users,DC=i12bretro,DC=local<br />
  66. &nbsp; &lt;/Location&gt; &nbsp;<br />
  67. &nbsp;&nbsp;&lt;Location &quot;/webdav&quot;&gt;<br />
  68. &nbsp; &nbsp; DAV On<br />
  69. &nbsp; &nbsp; AuthType &quot;Basic&quot;<br />
  70. &nbsp; &nbsp; AuthName &quot;webdav&quot;<br />
  71. &nbsp; &nbsp; Options Indexes<br />
  72. &nbsp; &nbsp; Header always set Access-Control-Allow-Origin &quot;*&quot;<br />
  73. &nbsp; &nbsp; Header always set Access-Control-Allow-Headers &quot;origin, content-type, cache-control, accept, authorization, if-match, destination, overwrite&quot;<br />
  74. &nbsp; &nbsp; Header always set Access-Control-Expose-Headers &quot;ETag&quot;<br />
  75. &nbsp; &nbsp; Header always set Access-Control-Allow-Methods &quot;GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK&quot;<br />
  76. &nbsp; &nbsp; Header always set Access-Control-Allow-Credentials &quot;true&quot;<br />
  77. &nbsp; &lt;/Location&gt;</p>
  78. </li>
  79. <li>Edit the index.html file and modify the kw-config meta tag, setting the value to config.json
  80. <div class="codeBlock"># <meta name="kw-config" content="config.json"><br />
  81. sudo nano /var/www/html/keepass/index.html</div>
  82. </li>
  83. <li>Press CTRL+O, Enter, CTRL+X to write the changes to index.html</li>
  84. <li>Create and edit config.json to by running the following command:
  85. <div class="codeBlock">sudo nano /var/www/html/keepass/config.json</div>
  86. </li>
  87. <li>Paste the following in to config.json
  88. <p>{<br />
  89. &nbsp;&nbsp; &nbsp;&quot;settings&quot;: {<br />
  90. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;theme&quot;: &quot;fb&quot;,<br />
  91. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;autoSave&quot;: true,<br />
  92. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;autoSaveInterval&quot;: 1,<br />
  93. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;canOpenDemo&quot;: false,<br />
  94. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;dropbox&quot;: false,<br />
  95. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;gdrive&quot;: false,<br />
  96. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;onedrive&quot;: false,<br />
  97. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;canExportXml&quot;: true<br />
  98. &nbsp;&nbsp; &nbsp;},<br />
  99. &nbsp;&nbsp; &nbsp;&quot;files&quot;: [{<br />
  100. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;storage&quot;: &quot;webdav&quot;,<br />
  101. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;name&quot;: &quot;Database&quot;,<br />
  102. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;path&quot;: &quot;/webdav/database.kdbx&quot;<br />
  103. &nbsp;&nbsp; &nbsp;}]<br />
  104. }</p>
  105. </li>
  106. <li>Press CTRL+O, Enter, CTRL+X to write the changes to config.json</li>
  107. <li>Continue by executing the following commands in terminal:
  108. <div class="codeBlock"># enable the keepass site and required Apache&nbsp;modules<br />
  109. sudo a2ensite keepass<br />
  110. sudo a2enmod dav dav_fs ldap authnz_ldap rewrite headers<br />
  111. # restart apache2 service for the changes to take effect<br />
  112. sudo systemctl restart apache2</div>
  113. </li>
  114. <li>Open a web browser and navigate to http://DNSorIP/keepass</li>
  115. <li>Authenticate with a valid LDAP user account</li>
  116. <li>Click the New icon</li>
  117. <li>Click the New link in the lower left hand corner</li>
  118. <li>Enter a Master password and re-type it to confirm</li>
  119. <li>Enter a Name for the keepass database</li>
  120. <li>Click the Save to... button &gt; File</li>
  121. <li>Save the database to ~/database.kdbx</li>
  122. <li>Close the browser</li>
  123. <li>Continue by executing the following commands in terminal:
  124. <div class="codeBlock"># copy the keepass database to webdav directory<br />
  125. sudo mv ~/database.kdbx /var/www/html/webdav/</div>
  126. </li>
  127. <li>Open a web browser and navigate to http://DNSorIP/keepass</li>
  128. <li>Enter the master password created earlier</li>
  129. <li>Enjoy your web based keepass editor</li>
  130. </ol> </div>
  131. </div>
  132. </body>
  133. </html>