Machine: Non root ssh create sudo can't get password

Created on 23 Jul 2015  路  9Comments  路  Source: docker/machine

Sudo tty password

I saw this but i don't know if it relates
https://github.com/ehazlett/machine/commit/b43a72f91aad5f3067ba406e54534bdd4b834fb4
maybe I don't know how the allocate the tty

My issue is that when using the generic driver to create a machine I do:

docker-machine -D create --driver generic \
  --generic-ip-address=example_host.example.com --generic-ssh-user=john \
  --generic-ssh-key=/home/john/.ssh/id_rsa.pub example_host

machine is able to log into example_host.example.com as john with the correct
key file, however it then attempts to run

sudo hostname example_host && echo "example_host" | sudo tee /etc/hostname

To which sudo replies

sudo: no tty present and no askpass program specified

when sudo trys to ask for john's password

Here is the full debug:

Importing SSH key...
IP: example_host.example.com
Getting to WaitForSSH function...
Testing TCP connection to: example_host.example.com:22
Using SSH client type: external
About to run SSH command:
exit 0
&{/usr/bin/ssh [/usr/bin/ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /home/john/.docker/machine/machines/example_host/id_rsa -p 22 john@example_host.example.com exit 0] []  <nil> <nil> <nil> [] <nil> <nil> <nil> ?reflect.Value? false [] [] [] [] <nil>}
SSH cmd err, output: <nil>:
Using SSH client type: external
About to run SSH command:
cat /etc/os-release
&{/usr/bin/ssh [/usr/bin/ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /home/john/.docker/machine/machines/example_host/id_rsa -p 22 john@example_host.example.com cat /etc/os-release] []  <nil> <nil> <nil> [] <nil> <nil> <nil> ?reflect.Value? false [] [] [] [] <nil>}
SSH cmd err, output: <nil>: NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

found compatible host: ubuntu
Using SSH client type: external
About to run SSH command:
sudo hostname example_host && echo "example_host" | sudo tee /etc/hostname
&{/usr/bin/ssh [/usr/bin/ssh -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /home/john/.docker/machine/machines/example_host/id_rsa -p 22 john@example_host.example.com sudo hostname example_host && echo "example_host" | sudo tee /etc/hostname] []  <nil> <nil> <nil> [] <nil> <nil> <nil> ?reflect.Value? false [] [] [] [] <nil>}
SSH cmd err, output: exit status 1: sudo: no tty present and no askpass program specified

Error creating machine: exit status 1
You will want to check the provider to make sure the machine and associated resources were properly removed.

Any ideas on what to do? I tried asking the irc

aressh drivegeneric

Most helpful comment

For people coming here in relation to docker multi-networking blog post

The only temporary fix is to let your user explicitly allow sudo to be used without a password.

edit /etc/sudoers and add YOURUSERNAME ALL=(ALL) NOPASSWD:ALL

Then it'll work.

This is until #1586 is merged

All 9 comments

I'm working on fixing this

I'm still working on this, Heres the repo if you want to use my version while I wait / hope to get my changes merged in https://github.com/pdxjohnny/docker-machine

My version works now so if you want to use that go ahead I'll leave this open until it gets merged in

hello @pdxjohnny could you get your changed merged in ? I could see the commit but not PR
https://github.com/pdxjohnny/machine/commit/7aaef89ba5345466661f60e83f9c48ab246f2d3a

https://github.com/docker/machine/pull/1586
I tried to it probably needs to be updated though

For people coming here in relation to docker multi-networking blog post

The only temporary fix is to let your user explicitly allow sudo to be used without a password.

edit /etc/sudoers and add YOURUSERNAME ALL=(ALL) NOPASSWD:ALL

Then it'll work.

This is until #1586 is merged

+1

I think https://github.com/docker/machine/pull/3085/files is sufficient to close this?

When you have such kind of problems, always check logs of target machine. In my case problem was - target machine was not able to - yum update.

Was this page helpful?
0 / 5 - 0 ratings