--- ../virnetclient.c	2013-06-26 18:24:49.212093296 +0200
+++ src/rpc/virnetclient.c	2013-06-27 12:18:54.663873762 +0200
@@ -37,6 +37,7 @@
 #include "virutil.h"
 #include "virerror.h"
 #include "virstring.h"
+#include "virauth.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
@@ -389,7 +390,9 @@
                                        const char *authMethods,
                                        const char *netcatPath,
                                        const char *socketPath,
-                                       virConnectAuthPtr authPtr)
+                                       virConnectAuthPtr authPtr,
+                                       virConnectPtr conn
+                                       )
 {
     virNetSocketPtr sock = NULL;
     virNetClientPtr ret = NULL;
@@ -402,6 +405,7 @@
     char *confdir = virGetUserConfigDirectory();
     char *knownhosts = NULL;
     char *privkey = NULL;
+    char *password = NULL;
 
     /* Use default paths for known hosts an public keys if not provided */
     if (confdir) {
@@ -471,11 +475,21 @@
     if (!(command = virBufferContentAndReset(&buf)))
         goto no_memory;
 
-    if (virNetSocketNewConnectLibSSH2(host, port, username, NULL, privkey,
+    password = virAuthGetPassword(conn, authPtr, "libssh2", username, host);
+
+    if ((strcmp(authMethods,"password") == 0) && password) {
+
+      if (virNetSocketNewConnectLibSSH2(host, port, username, password, privkey,
                                       knownhosts, knownHostsVerify, authMethods,
                                       command, authPtr, &sock) != 0)
         goto cleanup;
 
+    } else {
+      if (virNetSocketNewConnectLibSSH2(host, port, username, NULL, privkey,
+                                      knownhosts, knownHostsVerify, authMethods,
+                                      command, authPtr, &sock) != 0)
+          goto cleanup;
+    }
     if (!(ret = virNetClientNew(sock, NULL)))
         goto cleanup;
     sock = NULL;
