Machine: sudo: no tty present and no askpass program specified

Created on 29 Jun 2016  ·  5Comments  ·  Source: docker/machine

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.

Most helpful comment

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?

All 5 comments

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?

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.

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings