Closed jbryer closed 8 years ago
@jbryer how did you get rstudio installed? manually on the command line? using docklet_rstudio()
?
We recommend using ssh keys instead of passwords. If you use a password after setting up droplet, you should get the password in an email. Does that not happen?
Here's the full R code I am using:
d <- docklet_create(name = "EPSY530Summer2015", size = getOption("do_size", "512mb")) d %>% docklet_pull("rocker/hadleyverse") d %>% droplet_ssh("adduser --disabled-password --gecos '' testuser", verbose=TRUE) %>% droplet_ssh('echo "testuser:testpass" | sudo chpasswd', verbose=TRUE) d %>% docklet_run("-d", " -p 8787:8787", " -e USER=rstudio", " -e PASSWORD=rstudio ", "rocker/hadleyverse" ) %>% docklet_images() d %>% droplet_ssh('ls -la /home') # This shows testuser, but not rstudio user
I do not get the password via email when I start the droplet from R. I can get it if I do a password reset from the DO website.
Thanks, Jason
thanks @jbryer I'll have a look
Just another data point. I manually installed R and RStudio using the instructions here: http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/
The droplets()
function returns my droplet and I can create users using the droplet_ssh
calls I included above and it works. We'll see how this works tomorrow for my class (just 13 students so we'll see how many I can support on one droplet.
hey @cboettig - I imagine you've solved this issue before. How can we get a bunch of users added to the Rstudio server being created via docker?
@cboettig looks like this is helpful https://github.com/rocker-org/rocker/wiki/Using-the-RStudio-image#multiple-users - Although from analogsea, I'd like to do this non-interactively, and allow users to do this from this pkg, perhaps when they setup their droplet.
We have docklet_rstudio()
. Could add function docklet_rstudio_addusers()
or similar
yup -- there's a function we added on the rstudio-based images called add-students
that adds up to 100 student accounts with user name = user password of the form "user1", "user2" etc. The script has to be run as root, e.g. at runtime:
docker run -d -p 8787:8787 rocker/rstudio add-students && supervisord
should do it. Of course these aren't the most secure name and password combinations.
For a smaller group of students for longer term use, you might want to run the droplet with root access e.g.: docker run -d -p 8787:8787 -e ROOT=TRUE rocker/rstudio
and then just add them with a system call and custom user names and passwords; e.g. from inside R:
# replace USERNAME and PASSWORD appropriately
system("sudo useradd user$u && echo "USERNAME:PASSWORD" | chpasswd")
# make a home folder for user:
system("sudo mkdir /home/USERNAME && chown USERNAME:USERNAME /home/USERNAME")
## Optionally, let user install R packages into the global library:
system("sudo addgroup USERNAME staff")
Clearly that could be more elegantly wrapped by analogsea.
Alternatively, we could spin up an nginx proxy, serve over (self-signed if no professional cert is available) https. This means you could just use the add-students
script because the real security layer would be before then in signing into the https, and the script just lets students have separate workspaces and all sign in at the same time.
My understanding is that https isn't critical since rstudio encrypts passwords anyway with client-side libraries, but this approach would be easier particularly in contexts where the students already have logins for some proxy host -- e.g. when deploying on campus infrastructure rather than in the cloud.
nice, thanks @cboettig ! Playing with these now - my gut reaction is to not go with the nginx proxy, but we'll see
hmmm, i can spin up rstudio like
docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=rstudio rocker/rstudio
but this is erroring with exec format error
docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=rstudio rocker/rstudio add-students && supervisord
Whoops, my bad. Have to pass as a command string to bash. I think this should work
docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=rstudio rocker/rstudio bash -c "add-students && supervisord"
On Mon, Jun 1, 2015 at 4:53 PM Scott Chamberlain notifications@github.com wrote:
hmmm, i can spin up rstudio like
docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=rstudio rocker/rstudio
but this is erroring with exec format error
docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=rstudio rocker/rstudio add-students && supervisord
— Reply to this email directly or view it on GitHub https://github.com/sckott/analogsea/issues/101#issuecomment-107749029.
@cboettig sweet! that worked,
now to make it useable for others...
@jbryer How did the class go today, if it was today?
@jbryer reinstall, then try this
d <- docklet_create()
d %>% docklet_rstudio() %>% docklet_rstudio_addusers()
@sckott The class went well, thanks for asking. I had 13 students on a 1gb working on the first lab from the OpenIntro book and didn't have issues until the end of class. I was able to quickly restart with a 2gb instance and seems are working well for now. It is nice to change the server as needed.
Back to this issue, adding users through analogsea still doesn't work. Here is the code and error I am getting:
d <- docklet_create(name='TestRStudio')
d %>% docklet_rstudio()
d %>% docklet_rstudio_addusers(user='test', password='test')
Error:
time="2015-06-02T17:00:26-04:00" level=fatal msg="Error response from daemon: Cannot start container 7c0affadb6539b65df4e1c433033e81b725e2d0e71150fde6276f37d8c95a9e5: Bind for 0.0.0.0:8787 failed: port is already allocated"
Error: ssh failed
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/var/folders/68/1b6hk5t941gc2p97nsvkslpw0000gn/T//Rtmpm6dGdr/hosts root@198.199.113.235 'docker run -d -p 8787:8787 -e USER=test -e PASSWORD=test rocker/rstudio bash -c "add-students && supervisord"'
Hmm, looks like analogsea isn't shutting down previous docker instances. A previous docker instance probably has port 8787 already assigned to it. you could of course just use a different port, but it would be better to close down the previous instance first.
On Tue, Jun 2, 2015 at 2:03 PM Jason Bryer notifications@github.com wrote:
@sckott https://github.com/sckott The class went well, thanks for asking. I had 13 students on a 1gb working on the first lab from the OpenIntro book and didn't have issues until the end of class. I was able to quickly restart with a 2gb instance and seems are working well for now. It is nice to change the server as needed.
Back to this issue, adding users through analogsea still doesn't work. Here is the code and error I am getting:
d <- docklet_create(name='TestRStudio') d %>% docklet_rstudio() d %>% docklet_rstudio_addusers(user='test', password='test')
Error:
time="2015-06-02T17:00:26-04:00" level=fatal msg="Error response from daemon: Cannot start container 7c0affadb6539b65df4e1c433033e81b725e2d0e71150fde6276f37d8c95a9e5: Bind for 0.0.0.0:8787 failed: port is already allocated" Error: ssh failed ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/var/folders/68/1b6hk5t941gc2p97nsvkslpw0000gn/T//Rtmpm6dGdr/hosts root@198.199.113.235 'docker run -d -p 8787:8787 -e USER=test -e PASSWORD=test rocker/rstudio bash -c "add-students && supervisord"'
— Reply to this email directly or view it on GitHub https://github.com/sckott/analogsea/issues/101#issuecomment-108098267.
@jbryer Thanks for the feedback! I think @cboettig is right on that point. I'll see if I can help prevent that from happening.
hey @jbryer if you get a chance give the most recent version a try.
devtools::install_github("sckott/analogsea")
You can add users when installing rstudio
e <- docklet_create()
e %>% docklet_rstudio(add_users = TRUE) # false by default
Or, add users after installing rstudio, requires shutting down rstudio container, and starting a new one
e %>% docklet_rstudio_addusers()
@sckott Do you happen to be at useR? This still doesn't work for me and would love to meetup (buy a beer), and take a look.
@jbryer Hi! I decided not to go this year - wish I could meet up with you. when you get a chance, let me know what errors you run into, or is it the same as above https://github.com/sckott/analogsea/issues/101#issuecomment-108098267
@jbryer id be happy to do a call with you if you want to see if we can get this sorted
@jbryer happy to do a call if you want to chat about this, otherwise closing for now
It would be nice to have multiple RStudio users on the same droplet. I tried working around this with the following commands:
d %>% droplet_ssh("adduser --disabled-password --gecos '' testuser") d %>% droplet_ssh('echo "testuser:testpass" | sudo chpasswd')
Even though I don't get errors with these commands, the users are not created (i.e. I cannot login to RStudio with testuser/testpass).
On that note, is there a way to get the default root password that supposedly DO returns when the droplet is created?