Packer: SSH allocates a pty

Created on 31 Dec 2014  ยท  10Comments  ยท  Source: hashicorp/packer

Packer shouldn't request a pty by default after establishing an ssh session to the client. Doing so causes many programs like apt-get and git-clone to appear to hang inexplicably during the provisioning process, because Packer doesn't (and arguably shouldn't) forward data sent by programs to pty file descriptors to to the user. Also, if those programs call isatty(3) and it returns true, they'll try to read from the pty (which Packer cannot do) and often cannot be told not to.

If pty-less mode causes users problems, a FAQ can be published to help users devise workarounds.

bug core

Most helpful comment

All 10 comments

I believe Packer currently allocates a tty because of the default sudoers settings in RHEL/CentOS (namely: defaults requiretty). Our workaround is to disable it as follows:

ssh -i $SSH_KEY_FILE -t -t -o "StrictHostKeyChecking no" centos@$IP_ADDRESS <<EOF
sudo sed -i.bak -e '/Defaults.*requiretty/s/^/#/' /etc/sudoers
exit
EOF

Fixed by #1968

Hmm, just ran into this after upgrading to 0.8.0 and trying to provision a CentOS image on amazon-ebs. I keep getting the sudo: sorry, you must have a tty to run sudo error message during the puppet provisioning command step.

I had to add the suggested sed -i.bak -e '/Defaults.*requiretty/s/^/#/' /etc/sudoers line in a pre-puppet shell provisioning step to get it to work. So I'd say this is a bit of a BC break that might be worth documenting.

i too am having this issue with 0.8.0

@Rican7 This is noted in the changelog as a BC break: https://github.com/mitchellh/packer/blob/master/CHANGELOG.md#080-june-23-2015

@cbednarski Ah, thanks.

@cbednarski @Rican7 "This can be enabled per builder." how?

RedHat has removed the Defaults requiretty bit from _/etc/sudoers_ in RHEL7
references
https://bugzilla.redhat.com/show_bug.cgi?id=1196451
https://access.redhat.com/errata/RHSA-2016:2593

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frezbo picture frezbo  ยท  3Comments

tleyden picture tleyden  ยท  3Comments

mushon4 picture mushon4  ยท  3Comments

brettswift picture brettswift  ยท  3Comments

znerd picture znerd  ยท  3Comments