rocker-org / rocker

R configurations for Docker
https://rocker-project.org
GNU General Public License v2.0
1.46k stars 271 forks source link

new user is not able to login #170

Closed mictadlo closed 8 years ago

mictadlo commented 8 years ago

Hello, I added and commited a new user, but unfortunately I am not able to log in as the new user

$ docker run -it -p 8787:8787 rocker/ropensci /bin/bash
root@bf779e948d47:/# adduser galaxy
root@bf779e948d47:/# ls /home
galaxy  rstudio

[lorencm@galaxy ~]$ docker stop 7a50c602f0df
[lorencm@galaxy ~]$ docker run -d -p 8787:8787 -v /galaxy/downloads/:/home/galaxy rocker/ropensci

What did I do wrong?

Thank you in advance.

Mic

eddelbuettel commented 8 years ago

AFAIK that is 'just' how RStudio on Linux works -- we have the same issue with a regular RStudio server instance running at work. Paging @wch ...

Solution: Just ssh in (or equivalent) to have /home/galaxy created and populated so that RStudio can write its state files below it. There may be more a Unixy way to do this -- but it is not a Rocker issue so I suggest we close this.

cboettig commented 8 years ago

Looks like you are starting a new container the second time instead of restarting the one where you created the user

On Sun, Mar 20, 2016, 6:17 AM Dirk Eddelbuettel notifications@github.com wrote:

AFAIK that is 'just' how RStudio on Linux work -- we have the same with a regular RStudio server instance running at work. Paging @wch https://github.com/wch ...

Solution: Just ssh in (or equivalent) to have /home/galaxy populated. There may be more a Unixy way to do this -- but it is not a Rocker issue so I suggest we close this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/rocker-org/rocker/issues/170#issuecomment-198929569

http://carlboettiger.info

eddelbuettel commented 8 years ago

Ignore my earlier answer. I confused myself. We have that problem when the user is known to PAM/AD but has not yet been created on the box. Different issue. adduser creates the directory just fine.

MarkEdmondson1234 commented 8 years ago

Hi @eddelbuettel , may I ask for some detail on the fix you have about SSH?

I'm trying to add new users to an rocker/rstudio image via a script. I can execute the commands manually within the docker container fine, but via the script the new user login is not recognised.

Leaving the user as default root I get this error:

## adduser works fine
docker exec rstudio adduser myuser --gecos 'First Last,RoomNumber,WorkPone,HomePhone' --disabled-password
docker exec rstudio echo myuser:mypassword | sudo chpasswd
# chpasswd: (user myuser) pam_chauthtok() failed, error:
# User not known to the underlying authentication module
# chpasswd: (line 1, user myuser) password not changed

When I add a user rstudio it returns but I can't log in with the password:

## adduser works fine
## user rstudio to run in container also named rstudio
docker exec -u rstudio rstudio adduser myuser --gecos 'First Last,RoomNumber,WorkPone,HomePhone' --disabled-password

## returns, but password doesn't work
docker exec -u rstudio rstudio echo myuser:mypassword | sudo chpasswd

...but logging into the docker image and running the same commands do work:

docker exec -it rstudio bash
root@blah:/# adduser myuser --gecos 'First Last,RoomNumber,WorkPone,HomePhone' --disabled-password
root@blah:/# echo myuser:mypassword | sudo chpasswd

## can log in fine
cboettig commented 8 years ago

@mictadlo

In your command: docker exec rstudio echo myuser:mypassword | sudo chpasswd should be: docker exec rstudio sh -c "echo myuser:mypassword | sudo chpasswd" otherwise the pipe is not getting passed into the container but treated as a later shell command. (Also note the sudo isn't needed since we are root here already).

Same thing happens with your later command, docker exec -u rstudio rstudio echo myuser:mypassword | sudo chpasswd, though that one will also fail even with sh -c because user rstudio doesn't have sudo privileges.

hth,

Carl

MarkEdmondson1234 commented 8 years ago

Fantastic, it works! Thanks very much :)

Final commands are

docker exec rstudio adduser myuser --gecos 'First Last,RoomNumber,WorkPhone,HomePhone' --disabled-password

docker exec rstudio sh -c 'echo myuser myuser:mypassword | sudo chpasswd'

These are called via R functions, so now to add a user to a GCE instance running rocker/rstudio is:

library(googleComputeEngineR)
vm <- gce_vm("rstudio", user = "mark", password = "mark", name = "rstudio-cloud")
## ...wait for it to start up...
gce_rstudio_adduser(vm, "mark2", password = "blah")