From 82c3b4e685604f1767bbc48bf27441ca8a552eac Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 27 Mar 2013 16:41:54 -0400 Subject: [PATCH] now ssh connection plugin will only pass user as an option to ssh if it is differnt from the current user. This should enable overrides for user in .ssh/config w/o breaking any current functionality. Signed-off-by: Brian Coca --- lib/ansible/runner/connection_plugins/ssh.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index b7043a149d..f4e502b4e8 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -23,6 +23,7 @@ import pipes import random import select import fcntl +import pwd import ansible.constants as C from ansible.callbacks import vvv from ansible import errors @@ -62,7 +63,8 @@ class Connection(object): else: self.common_args += ["-o", "KbdInteractiveAuthentication=no", "-o", "PasswordAuthentication=no"] - self.common_args += ["-o", "User="+self.user] + 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