From e9f770fa11ffd52474db295b2ed7807710ff0415 Mon Sep 17 00:00:00 2001 From: John Kleint Date: Fri, 1 Jun 2012 17:16:02 -0400 Subject: [PATCH] More helpful message when ssh fails. --- lib/ansible/runner/connection/paramiko_ssh.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner/connection/paramiko_ssh.py b/lib/ansible/runner/connection/paramiko_ssh.py index fb58b42ae4..add2d3a1fb 100644 --- a/lib/ansible/runner/connection/paramiko_ssh.py +++ b/lib/ansible/runner/connection/paramiko_ssh.py @@ -65,10 +65,15 @@ class ParamikoConnection(object): port=self.port ) except Exception, e: - if str(e).find("PID check failed") != -1: + msg = str(e) + if "PID check failed" in msg: raise errors.AnsibleError("paramiko version issue, please upgrade paramiko on the machine running ansible") + elif "Private key file is encrypted" in msg: + msg = 'ssh %s@%s:%s : %s\nTo connect as a different user, use -u .' % ( + user, self.host, self.port, msg) + raise errors.AnsibleConnectionFailed(msg) else: - raise errors.AnsibleConnectionFailed(str(e)) + raise errors.AnsibleConnectionFailed(msg) return ssh