From 27cdffe0426cd41de010b6ac10e546bb5b3130d2 Mon Sep 17 00:00:00 2001 From: Xiaohui Liu Date: Thu, 22 Oct 2015 16:14:47 +0800 Subject: [PATCH] force tty allocation for ssh with multiple '-tt'. fix #2037: when provision on CentOS 7.0, it needs to force tty allocation with multiple '-t' option. Otherwise, the ssh command will failed with "sudo: sorry, you must have a tty to run sudo" in SetHostname. Signed-off-by: Xiaohui Liu --- libmachine/provision/redhat.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libmachine/provision/redhat.go b/libmachine/provision/redhat.go index cd6462ac26..f14752d1ef 100644 --- a/libmachine/provision/redhat.go +++ b/libmachine/provision/redhat.go @@ -73,10 +73,12 @@ func (provisioner *RedHatProvisioner) SSHCommand(args string) (string, error) { } // redhat needs "-t" for tty allocation on ssh therefore we check for the - // external client and add as needed + // external client and add as needed. + // Note: CentOS 7.0 needs multiple "-tt" to force tty allocation when ssh has + // no local tty. switch c := client.(type) { case ssh.ExternalClient: - c.BaseArgs = append(c.BaseArgs, "-t") + c.BaseArgs = append(c.BaseArgs, "-tt") client = c case ssh.NativeClient: return c.OutputWithPty(args)