Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

sudo: no tty present and no askpass program specified #3554

Open
m-amr opened this issue Jun 29, 2016 · 5 comments
Open

sudo: no tty present and no askpass program specified #3554

m-amr opened this issue Jun 29, 2016 · 5 comments

Comments

@m-amr
Copy link

m-amr commented Jun 29, 2016

I am using MacOSX Captain as a host operating system
I have created a container from Ubuntu Images
The container bash run with root user by default

I have installed sudo through apt-get
then i had created non privileged user called test-user

i run the bash with test-user
docker exec -i -t -u test-user container-id bash

when i try to use sudo apt-get install
I get this error sudo: no tty present and no askpass program specified

I am trying to that because i read that i shouldn't use root or admin user to run any program because it will be a security problem.

@4gatepylon
Copy link

4gatepylon commented Jun 30, 2016

I have the same problem. For some people going to /etc/sudoers (sudoers is a file) and adding username ALL=(ALL) NOPASSWD: ALL (making it so that you don't need the password) works, so maybe you can try it out, but it hasn't worked for me. Anyone else got better suggestions?

@m-amr
Copy link
Author

m-amr commented Jun 30, 2016

Yes it works for me,
try to edit the file using visudo command and make sure that you have entered the username correctly, but I am not sure that this solution is secured, if you forget to close the terminal anyone who use your laptop will use sudo command without a password to inject any program.

I am trying to find a way to enter password, but it is not working.

@joanrodriguez
Copy link

This also worked for me, use your actual username and not username

@holgerbrandl
Copy link

Same problem here. Although I have sudo permissions on the remote machine running docker, it somehow seems wrong to mess with the remote sudoers configuration to create a local docker-machine configuration.

@git-blame
Copy link

Similar issue. When building for aws, the default docker-machine ssh user is ubuntu. I'm trying to either create a different sudo user (something friendlier like demouser) or rename ubuntu user after I finish creating the remote VM.

In both cases, you can use (or script) similar instructions as from https://askubuntu.com/questions/34074/how-do-i-change-my-username. In a nutshell:

  • Add new or temporary sudo user
  • Optional:
    • Login as new/temporary user and change the name/home dir of ubuntu user

Both steps have the same issue, the new user or the changed "ubuntu" user requires you to specify a password for sudo to work. Unless you edit the sudoers file to set-up nopasswd option. There is some secret sauce with the original "ubuntu" (default) user which allows a password-less sudo despite no extra configuration in sudoers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants