title: Securing vagrant box and adding new user with a password
body: <p>I'm provisioning a vagrant box based on <code>bento/debian-9.6</code></p>
  
  <p>My goal is to install <code>rstudio-server</code> and for the network to be bridged for remote accessibility.</p>
  
  <p>The issue I'm having is that <code>rstudio-server</code> uses <a href="https://support.rstudio.com/hc/en-us/articles/221303588-What-is-my-username-on-my-RStudio-Server-" rel="nofollow noreferrer">PAM authentication</a>  This means that the default <code>vagrant</code> user has access to <code>rstudio-server</code> with the password <code>vagrant</code>.</p>
  
  <p>What is the best way to add a new user (e.g. <code>rstudiouser</code>) secured with a password in the context of a vagrant provision?  I found a way to <a href="https://unix.stackexchange.com/questions/167919/adding-ubuntu-user-to-vagrant-ubuntu-instance">add a user using an ssh key</a> but this doesn't work for me as the <code>rstudio-server</code> needs the user to have a password.  Though I'll need my user to have sFTP access to the vagrant box so I'll need to create an ssh key also.</p>
  
  <p>What is the best way to secure the server since it will be available publicly since the <code>vagrant</code> and <code>root</code> user passwords and ssh keys are publicly known?</p>
  
  <p>Below is my current provisioning script</p>
  
  <pre><code>  config.vm.provision "shell", inline: &lt;&lt;-SHELL
       export DEBIAN_FRONTEND=noninteractive
       sudo apt-get update
       sudo apt-get -y install apt-transport-https dirmngr ca-certificates software-properties-common gnupg2
       sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
       sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian stretch-cran35/'
       sudo apt-get update
       sudo apt-get -y install r-base r-base-dev gdebi-core libcurl4-gnutls-dev libxml2-dev libssl-dev build-essential gdebi-core git
       wget https://download2.rstudio.org/server/debian9/x86_64/rstudio-server-1.2.1335-amd64.deb
       sudo gdebi --n rstudio-server-1.2.1335-amd64.deb
       sudo bash -c "echo 'www-port=80' &gt;&gt; /etc/rstudio/rserver.conf"
       sudo rstudio-server restart
       sudo R -e "install.packages(c('devtools', 'Seurat'), repos = 'https://cran.rstudio.com/', dep = TRUE)"
       SHELL
  </code></pre>