0166.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Install a Self-Hosted Bitwarden/Vaultwarden Password Vault on Debian</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Self-Hosted Bitwarden Server,Bitwarden Install Guide,Install Guide,Self-Hosted Password Vault,Debian,Linux,Bitwarden,Vaultwarden,Password Vault,Password Manager,Self-Hosted,Homelab,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Install a Self-Hosted Bitwarden/Vaultwarden Password Vault on Debian">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  12. <script type="text/javascript">
  13. $(function(){
  14. $('textarea').each(function(i,e){
  15. theTextarea = $(this);
  16. theTextarea.height((theTextarea[0].scrollHeight-5) +'px');
  17. });
  18. $('li').each(function(i,e){
  19. if(!$(this).hasClass('noCheckbox')){
  20. var uuid = 'li_' + Math.floor(Math.random() * Math.floor(1000000)).toString() + '_' + i.toString();
  21. $(this).contents().wrap('<span id="'+ uuid +'"><label for="cb_'+ uuid +'"></label></span>');
  22. $(this).prepend('<input type="checkbox" class="completeBox" id="cb_' + uuid +'" rel="'+ uuid +'" />')
  23. }
  24. });
  25. $('code,div.codeBlock,textarea.codeBlock').each(function(i,e){
  26. theElement = $(this);
  27. var lines = theElement.html().split("\n");
  28. theElement.empty();
  29. for(l=0;l<lines.length;l++){
  30. if($.trim(lines[l]) != '' && $.trim(lines[l]).substr(0,1) != '#' && $.trim(lines[l]).indexOf(' #') == -1 && lines[l].substr(0, 4).toUpperCase() != 'REM '){
  31. 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>');
  32. } else {
  33. theElement.append(lines[l]);
  34. }
  35. }
  36. });
  37. $(document).on('click','input.copy-text',function(){
  38. theButton = $(this);
  39. $('input.copy-text').attr('src','images/clipboard.png');
  40. $('span.copy-animation,span.copy-animation-ps').removeClass('copy-animation copy-animation-ps');
  41. try {
  42. if($('#'+ theButton.attr('rel')).parent('div').hasClass('PS')){
  43. $('#'+ theButton.attr('rel')).addClass('copy-animation-ps');
  44. } else if($('#'+ theButton.attr('rel')).parent('div').hasClass('CMD')){
  45. $('#'+ theButton.attr('rel')).addClass('copy-animation-cmd');
  46. } else {
  47. $('#'+ theButton.attr('rel')).addClass('copy-animation');
  48. }
  49. navigator.clipboard.writeText(theButton.data('clipboard-text').replace(/<[^>]*>?/gm, ''));
  50. theButton.attr('src','images/clipboard_active.png');
  51. } catch(err) {
  52. }
  53. return false;
  54. });
  55. $(document).on('click','input.completeBox',function(){
  56. theBox = $(this);
  57. $('#'+ theBox.attr('rel')).addClass('strikethrough');
  58. theBox.prop('disabled',true);
  59. theBox.parent('li').prevAll().each(function(i,e){
  60. theLI = $(this);
  61. if(theLI.find('input[type=checkbox]').not(':checked')){
  62. $('#'+ theLI.find('input[type=checkbox]').attr('rel')).addClass('strikethrough');
  63. theLI.find('input[type=checkbox]').prop('checked',true).prop('disabled',true);
  64. }
  65. });
  66. });
  67. if(window.self !== window.top){
  68. window.parent.$('iframe.stepsFrame').height((this['scrollingElement']['scrollHeight']+20) +'px');
  69. }
  70. });
  71. </script>
  72. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  73. </head>
  74. <body>
  75. <div id="gridContainer">
  76. <div class="topMargin"></div>
  77. <div id="listName" class="topMargin">
  78. <h1>Install a Self-Hosted Bitwarden/Vaultwarden Password Vault on Debian</h1>
  79. </div>
  80. <div></div>
  81. <div id="content">
  82. <h2>What is Bitwarden?</h2>
  83. <p><em>Bitwarden is a free and open-source password management service that stores sensitive information such as website credentials in an encrypted vault. The Bitwarden platform offers a variety of client applications including a web interface, desktop applications, browser extensions, mobile apps, and a CLI. Bitwarden offers a cloud-hosted service as well as the ability to deploy the solution on-premises. - <a href="https://en.wikipedia.org/wiki/Bitwarden" target="_blank">https://en.wikipedia.org/wiki/Bitwarden</a></em></p>
  84. <h2>Install Bitwarden/Vaultwarden</h2>
  85. <ol>
  86. <li>Log into the Linux device</li>
  87. <li>Run the following commands in a terminal window
  88. <div class="codeBlock"># update software repositories<br />
  89. sudo apt update<br />
  90. # install available software updates<br />
  91. sudo apt upgrade -y<br />
  92. # install prerequisites<br />
  93. sudo apt install git curl build-essential pkg-config libssl-dev openssl libssl1.1 libmariadb-dev-compat libmariadb-dev -y<br />
  94. # add nodejs software repository<br />
  95. curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -<br />
  96. # install nodejs<br />
  97. sudo apt install nodejs -y<br />
  98. # install rust, enter 1 at the prompt<br />
  99. curl https://sh.rustup.rs -sSf | sudo sh<br />
  100. # configure the shell<br />
  101. source $HOME/.cargo/env<br />
  102. # clone vaultwarden from git<br />
  103. git clone https://github.com/dani-garcia/vaultwarden.git ./vaultwarden<br />
  104. # cd into the new directory<br />
  105. cd vaultwarden/<br />
  106. # checkout latest version<br />
  107. git checkout &quot;$(git tag --sort=v:refname | tail -n1)&quot;<br />
  108. # build vaultwarden with mysql support<br />
  109. cargo build --features mysql,sqlite --release<br />
  110. # cd back one directory<br />
  111. cd ..<br />
  112. # clone web from git<br />
  113. git clone https://github.com/bitwarden/web.git ./web<br />
  114. # cd into the new web<br />
  115. cd web/<br />
  116. # checkout the latest version<br />
  117. git checkout &quot;$(git tag --sort=v:refname | tail -n1)&quot;<br />
  118. # update submodule<br />
  119. git submodule update --init --recursive<br />
  120. # download web patch<br />
  121. wget https://raw.githubusercontent.com/dani-garcia/bw_web_builds/master/patches/$(git tag --sort=v:refname | tail -n1).patch<br />
  122. # apply patch<br />
  123. git apply $(git tag --sort=v:refname | tail -n1).patch --verbose<br />
  124. # clean npm cache<br />
  125. npm cache clean --force<br />
  126. # initialize npm<br />
  127. npm run sub:init<br />
  128. # install npm dependencies<br />
  129. npm install<br />
  130. # fix npm vulnerabilities<br />
  131. npm audit fix<br />
  132. # build web vault<br />
  133. npm run dist<br />
  134. # copy the build directory into vaultwarden/web-vault<br />
  135. cp -a build ../vaultwarden/target/release/web-vault<br />
  136. # cd into vaultwarden<br />
  137. cd ../vaultwarden/target/release/<br />
  138. # create a data directory<br />
  139. mkdir data<br />
  140. # run vaultwarden<br />
  141. ./vaultwarden</div>
  142. </li>
  143. <li>Open a web browser and navigate to https://DNSorIP:8000</li>
  144. <li>Click the Create Account button</li>
  145. <li>Complete the form by entering an Email Address, Name, Master Password and Password Hint (optional) &gt; Click Submit</li>
  146. <li>Login with the account created in the last step</li>
  147. <li>Welcome to your self-hosted Bitwarden password vault</li>
  148. </ol>
  149. <h2>Run Bitwarden/Vaultwarden as a Service (Optional, but recommended)</h2>
  150. <ol>
  151. <li>Press CTRL + C to kill the running Vaultwarden process</li>
  152. <li>Continue with the following steps to run Vaultwarden as a service
  153. <div class="codeBlock"># cd to vaultwarden/target/release<br />
  154. cd ~/vaultwarden/target/release<br />
  155. # copy the .env template<br />
  156. sudo cp ../../.env.template /etc/vaultwarden.env<br />
  157. # copy vaultwarden executable<br />
  158. sudo cp vaultwarden /usr/bin/vaultwarden<br />
  159. # make vaultwarden executable<br />
  160. sudo chmod +x /usr/bin/vaultwarden<br />
  161. # create vaultwarden user<br />
  162. sudo useradd -m -d /var/lib/vaultwarden vaultwarden<br />
  163. # copy existing data directory<br />
  164. sudo cp -R data /var/lib/vaultwarden/<br />
  165. # copy web-vault directory<br />
  166. sudo cp -R web-vault /var/lib/vaultwarden/<br />
  167. # set ownership permissions<br />
  168. sudo chown -R vaultwarden:vaultwarden /var/lib/vaultwarden<br />
  169. # create service file<br />
  170. sudo nano /etc/systemd/system/vaultwarden.service</div>
  171. </li>
  172. <li>Paste the following configuration into vaultwarden.service
  173. <p>[Unit]<br />
  174. Description=Vaultwarden Server<br />
  175. <br />
  176. # Only sqlite<br />
  177. After=network.target</p>
  178. <p>[Service]<br />
  179. User=vaultwarden<br />
  180. Group=vaultwarden<br />
  181. EnvironmentFile=/etc/vaultwarden.env<br />
  182. ExecStart=/usr/bin/vaultwarden<br />
  183. PrivateTmp=true<br />
  184. PrivateDevices=true<br />
  185. ProtectHome=true<br />
  186. ProtectSystem=strict<br />
  187. WorkingDirectory=/var/lib/vaultwarden<br />
  188. ReadWriteDirectories=/var/lib/vaultwarden<br />
  189. AmbientCapabilities=CAP_NET_BIND_SERVICE</p>
  190. <p>[Install]<br />
  191. WantedBy=multi-user.target</p>
  192. </li>
  193. <li>Press CTRL+O, Enter, CTRL+X to write the changes to vaultwarden.service</li>
  194. <li>Continue with the following commands to enable the site and start vaultwarden:
  195. <div class="codeBlock"># reload systemd services<br />
  196. sudo systemctl daemon-reload<br />
  197. # start vaultwarden service on boot and now<br />
  198. sudo systemctl enable vaultwarden --now</div>
  199. </li>
  200. <li>Refresh the open web browser to verify Bitwarden is accessible</li>
  201. </ol>
  202. </div>
  203. </div>
  204. </body>
  205. </html>