diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index ca6fdb3a6ff..ec5d6edd340 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -94,7 +94,8 @@ class Connection(object): self.common_args += ["-o", "KbdInteractiveAuthentication=no", "-o", "PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey", "-o", "PasswordAuthentication=no"] - self.common_args += ["-o", "User=" + (self.user or pwd.getpwuid(os.geteuid())[0])] + if self.user != pwd.getpwuid(os.geteuid())[0]: + self.common_args += ["-o", "User="+self.user] self.common_args += ["-o", "ConnectTimeout=%d" % self.runner.timeout] return self