0233.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  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. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  7. <script type="text/javascript">
  8. $(function(){
  9. $('textarea').each(function(i,e){
  10. theTextarea = $(this);
  11. theTextarea.height((theTextarea[0].scrollHeight-5) +'px');
  12. });
  13. $('li').each(function(i,e){
  14. if(!$(this).hasClass('noCheckbox')){
  15. var uuid = 'li_' + Math.floor(Math.random() * Math.floor(1000000)).toString() + '_' + i.toString();
  16. $(this).contents().wrap('<span id="'+ uuid +'"><label for="cb_'+ uuid +'"></label></span>');
  17. $(this).prepend('<input type="checkbox" class="completeBox" id="cb_' + uuid +'" rel="'+ uuid +'" />')
  18. }
  19. });
  20. $('code,div.codeBlock,textarea.codeBlock').each(function(i,e){
  21. theElement = $(this);
  22. var lines = theElement.html().split("\n");
  23. theElement.empty();
  24. for(l=0;l<lines.length;l++){
  25. if($.trim(lines[l]) != '' && $.trim(lines[l]).substr(0,1) != '#' && $.trim(lines[l]).indexOf(' #') == -1 && lines[l].substr(0, 4).toUpperCase() != 'REM '){
  26. theElement.append('<input type="image" src="images/clipboard.png" value="" class="copy-text" rel="copy_'+ i +'_'+ l +'" data-clipboard-text="'+ $.trim(lines[l].replace(/"/g, '&quot;')) +'" /><span id="copy_'+ i +'_'+ l +'">'+ lines[l] +'</span>');
  27. } else {
  28. theElement.append(lines[l]);
  29. }
  30. }
  31. });
  32. $(document).on('click','input.copy-text',function(){
  33. theButton = $(this);
  34. $('input.copy-text').attr('src','images/clipboard.png');
  35. $('span.copy-animation,span.copy-animation-ps').removeClass('copy-animation copy-animation-ps');
  36. try {
  37. if($('#'+ theButton.attr('rel')).parent('div').hasClass('PS')){
  38. $('#'+ theButton.attr('rel')).addClass('copy-animation-ps');
  39. } else if($('#'+ theButton.attr('rel')).parent('div').hasClass('CMD')){
  40. $('#'+ theButton.attr('rel')).addClass('copy-animation-cmd');
  41. } else {
  42. $('#'+ theButton.attr('rel')).addClass('copy-animation');
  43. }
  44. navigator.clipboard.writeText(theButton.data('clipboard-text').replace(/<[^>]*>?/gm, ''));
  45. theButton.attr('src','images/clipboard_active.png');
  46. } catch(err) {
  47. }
  48. return false;
  49. });
  50. $(document).on('click','input.completeBox',function(){
  51. theBox = $(this);
  52. $('#'+ theBox.attr('rel')).addClass('strikethrough');
  53. theBox.prop('disabled',true);
  54. theBox.parent('li').prevAll().each(function(i,e){
  55. theLI = $(this);
  56. if(theLI.find('input[type=checkbox]').not(':checked')){
  57. $('#'+ theLI.find('input[type=checkbox]').attr('rel')).addClass('strikethrough');
  58. theLI.find('input[type=checkbox]').prop('checked',true).prop('disabled',true);
  59. }
  60. });
  61. });
  62. if(window.self !== window.top){
  63. window.parent.$('iframe.stepsFrame').height((this['scrollingElement']['scrollHeight']+20) +'px');
  64. }
  65. });
  66. </script>
  67. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  68. </head>
  69. <body>
  70. <div id="gridContainer">
  71. <div class="topMargin"></div>
  72. <div id="listName" class="topMargin">
  73. <h1>Create a Secure Web Based Password Vault with Keepass Web</h1>
  74. </div>
  75. <div></div>
  76. <div id="content">
  77. <ol>
  78. <li>Log into the Debian device</li>
  79. <li>Run the following commands in a terminal:
  80. <div class="codeBlock"># update repositories and install any available software updates<br />
  81. sudo apt&nbsp;update<br />
  82. sudo apt&nbsp;upgrade<br />
  83. # install apache2<br />
  84. sudo apt install apache2<br />
  85. # download and extract keepass web<br />
  86. wget https://github.com/keeweb/keeweb/archive/gh-pages.zip<br />
  87. sudo unzip gh-pages.zip -d /var/www/html/<br />
  88. sudo mv /var/www/html/keeweb-gh-pages /var/www/html/keepass<br />
  89. # create webdav directory and set permissions<br />
  90. sudo mkdir /var/www/html/webdav<br />
  91. sudo chown -R www-data:www-data /var/www/html/webdav<br />
  92. # change permissions on the newly setup application folder<br />
  93. sudo chown -R www-data:www-data /var/www/html/keepass<br />
  94. # create a new keepass.conf file to configure the site<br />
  95. sudo nano /etc/apache2/sites-available/keepass.conf</div>
  96. </li>
  97. <li>Paste the following directives into keepass.conf
  98. <p>DavLockDB &quot;/var/www/html/webdav/DavLock&quot;<br />
  99. &nbsp; &lt;Location /keepass &gt;<br />
  100. &nbsp; RewriteEngine on<br />
  101. &nbsp; RewriteCond %{REQUEST_METHOD} OPTIONS<br />
  102. &nbsp; RewriteRule ^(.*)$ blank.html [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]<br />
  103. &nbsp; # Don&#39;t require LDAP authentication for a healthcheck<br />
  104. &nbsp; SetEnvIf Request_URI &quot;^/healhcheck&quot; accessgranted=1<br />
  105. &nbsp; &nbsp; Order deny,allow<br />
  106. &nbsp; &nbsp; Satisfy any<br />
  107. &nbsp; &nbsp; Deny from all<br />
  108. &nbsp; &nbsp; Allow from env=accessgranted<br />
  109. &nbsp; &nbsp; AuthType Basic<br />
  110. &nbsp; &nbsp; AuthBasicProvider ldap<br />
  111. &nbsp; &nbsp; AuthLDAPURL &quot;ldap://i12bretro.local:389/DC=i12bretro,DC=local?sAMAccountName?sub?(objectClass=user)&quot; NONE<br />
  112. &nbsp; &nbsp; AuthLDAPBindDN &quot;readonly_svc@i12bretro.local&quot;<br />
  113. &nbsp; &nbsp; AuthLDAPBindPassword &quot;Read0nly!!&quot;<br />
  114. &nbsp; &nbsp; AuthName &quot;Restricted Area [i12bretro.local]&quot;<br />
  115. &nbsp; &nbsp; # to authenticate a domain group, specify the full DN<br />
  116. &nbsp; &nbsp; AuthLDAPGroupAttributeIsDN on<br />
  117. &nbsp; &nbsp; require ldap-group CN=WebAuthAccess,CN=Users,DC=i12bretro,DC=local<br />
  118. &nbsp; &lt;/Location&gt; &nbsp;<br />
  119. &nbsp;&nbsp;&lt;Location &quot;/webdav&quot;&gt;<br />
  120. &nbsp; &nbsp; DAV On<br />
  121. &nbsp; &nbsp; AuthType &quot;Basic&quot;<br />
  122. &nbsp; &nbsp; AuthName &quot;webdav&quot;<br />
  123. &nbsp; &nbsp; Options Indexes<br />
  124. &nbsp; &nbsp; Header always set Access-Control-Allow-Origin &quot;*&quot;<br />
  125. &nbsp; &nbsp; Header always set Access-Control-Allow-Headers &quot;origin, content-type, cache-control, accept, authorization, if-match, destination, overwrite&quot;<br />
  126. &nbsp; &nbsp; Header always set Access-Control-Expose-Headers &quot;ETag&quot;<br />
  127. &nbsp; &nbsp; Header always set Access-Control-Allow-Methods &quot;GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK&quot;<br />
  128. &nbsp; &nbsp; Header always set Access-Control-Allow-Credentials &quot;true&quot;<br />
  129. &nbsp; &lt;/Location&gt;</p>
  130. </li>
  131. <li>Edit the index.html file and modify the kw-config meta tag, setting the value to config.json
  132. <div class="codeBlock"># <meta name="kw-config" content="config.json"><br />
  133. sudo nano /var/www/html/keepass/index.html</div>
  134. </li>
  135. <li>Press CTRL+O, Enter, CTRL+X to write the changes to index.html</li>
  136. <li>Create and edit config.json to by running the following command:
  137. <div class="codeBlock">sudo nano /var/www/html/keepass/config.json</div>
  138. </li>
  139. <li>Paste the following in to config.json
  140. <p>{<br />
  141. &nbsp;&nbsp; &nbsp;&quot;settings&quot;: {<br />
  142. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;theme&quot;: &quot;fb&quot;,<br />
  143. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;autoSave&quot;: true,<br />
  144. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;autoSaveInterval&quot;: 1,<br />
  145. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;canOpenDemo&quot;: false,<br />
  146. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;dropbox&quot;: false,<br />
  147. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;gdrive&quot;: false,<br />
  148. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;onedrive&quot;: false,<br />
  149. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;canExportXml&quot;: true<br />
  150. &nbsp;&nbsp; &nbsp;},<br />
  151. &nbsp;&nbsp; &nbsp;&quot;files&quot;: [{<br />
  152. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;storage&quot;: &quot;webdav&quot;,<br />
  153. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;name&quot;: &quot;Database&quot;,<br />
  154. &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&quot;path&quot;: &quot;/webdav/database.kdbx&quot;<br />
  155. &nbsp;&nbsp; &nbsp;}]<br />
  156. }</p>
  157. </li>
  158. <li>Press CTRL+O, Enter, CTRL+X to write the changes to config.json</li>
  159. <li>Continue by executing the following commands in terminal:
  160. <div class="codeBlock"># enable the keepass site and required Apache&nbsp;modules<br />
  161. sudo a2ensite keepass<br />
  162. sudo a2enmod dav dav_fs ldap authnz_ldap rewrite headers<br />
  163. # restart apache2 service for the changes to take effect<br />
  164. sudo systemctl restart apache2</div>
  165. </li>
  166. <li>Open a web browser and navigate to http://DNSorIP/keepass</li>
  167. <li>Authenticate with a valid LDAP user account</li>
  168. <li>Click the New icon</li>
  169. <li>Click the New link in the lower left hand corner</li>
  170. <li>Enter a Master password and re-type it to confirm</li>
  171. <li>Enter a Name for the keepass database</li>
  172. <li>Click the Save to... button &gt; File</li>
  173. <li>Save the database to ~/database.kdbx</li>
  174. <li>Close the browser</li>
  175. <li>Continue by executing the following commands in terminal:
  176. <div class="codeBlock"># copy the keepass database to webdav directory<br />
  177. sudo mv ~/database.kdbx /var/www/html/webdav/</div>
  178. </li>
  179. <li>Open a web browser and navigate to http://DNSorIP/keepass</li>
  180. <li>Enter the master password created earlier</li>
  181. <li>Enjoy your web based keepass editor</li>
  182. </ol>
  183. </div>
  184. </div>
  185. </body>
  186. </html>