Bug 1452389 - Unable to connect to remote host via SSH with domain credentials
Summary: Unable to connect to remote host via SSH with domain credentials
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: virt-manager
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Cole Robinson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-18 20:41 UTC by David Zampino
Modified: 2017-08-26 01:34 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-08-26 01:34:15 UTC
Embargoed:


Attachments (Terms of Use)
Virt Manager debug log (11.93 KB, text/plain)
2017-06-01 15:28 UTC, David Zampino
no flags Details
Virt Manager Debug log 2 (4.00 KB, text/plain)
2017-06-01 21:33 UTC, David Zampino
no flags Details
Test with \ and 5%C (7.73 KB, text/plain)
2017-06-30 17:12 UTC, David Zampino
no flags Details
Debug with connection.py debug code (14.86 KB, text/plain)
2017-07-27 21:52 UTC, David Zampino
no flags Details
virt-manager debug logs 2017-8-21 (25.81 KB, text/plain)
2017-08-21 16:03 UTC, David Zampino
no flags Details

Description David Zampino 2017-05-18 20:41:48 UTC
Description of problem: 
Virt-manager throws a parsing error when trying to connect to a remote host using SSH where the username is a Windows domain username (e.g. domain\username or username). 


Version-Release number of selected component (if applicable): 
1.4.0


How reproducible:
Every time


Steps to Reproduce:
1. Create a new connection in Virtual Machine Manager
2. Select SSH under Method 
3. In username, put domain user name (e.g. lan\david or 
   david.com)
4. Put in hostname
5. Connect

Actual results:
Immediate error message

Expected results:
Connect to server

Additional info:
Error message displayed:
Unable to connect to libvirt.

internal error: Unable to parse URI qemu+ssh://lan\user-example@computername/system

Verify that the 'libvirtd' daemon is running
on the remote host.

Libvirt URI is: qemu+ssh://lan\user-example@computername/system

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/connection.py", line 904, in _do_open
    self._backend.open(self._do_creds_password)
  File "/usr/share/virt-manager/virtinst/connection.py", line 148, in open
    open_flags)
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 105, in openAuth
    if ret is None:raise libvirtError('virConnectOpenAuth() failed')
libvirtError: internal error: Unable to parse URI qemu+ssh://lan\user-example@computername/system

Comment 1 Cole Robinson 2017-05-18 21:34:10 UTC
Thanks for the report. Can you try replacing the \ with %5C and see if it works? If not, please post the error

Comment 2 David Zampino 2017-05-19 14:25:30 UTC
That seemed to work. It let me continue and put in the password, but fails with authentication unavailable: no polkit agent, which I believe to be a misconfiguration on my part

Comment 3 David Zampino 2017-05-19 19:12:57 UTC
It worked. Thank you for the assistance.

Comment 4 David Zampino 2017-05-19 19:43:19 UTC
Unfortunately, there is a follow up. When trying to open a VM it attempts to use %5C in the credentials (e.g. lan%5Cuser) and fails each time

Comment 5 Cole Robinson 2017-05-31 22:16:03 UTC
Can you post the virt-manager --debug output when reproducing that error as well?

Note, virt-manager should be changed to handle this URI escaping automatically, I'm just trying to get the full picture

Comment 6 David Zampino 2017-06-01 15:28:45 UTC
Created attachment 1284176 [details]
Virt Manager debug log

Comment 7 David Zampino 2017-06-01 15:31:18 UTC
I have attached the debug log as requested. During this debug I went through both sets of errors: the initial one where it fails to connect and the second one where it fails to open up the VM viewer because it's trying to authenticate with the %5C in the username

Comment 8 Cole Robinson 2017-06-01 18:29:56 UTC
Thanks for the info. I pushed this commit which hopefully fixes things:

commit 1d0b4a0a9e754a3d0d4da17ca88a0be29107ff5e (HEAD -> master, origin/master, origin/HEAD)
Author: Cole Robinson <crobinso>
Date:   Thu Jun 1 14:14:49 2017 -0400

    connect: Handle \ in username
    
    We need to quote URL values in the username, that's what libvirt expects.
    Unquote the values before caching them in the URI object, so console
    connections continue to work
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1452389


Can you give it a test?

git clone git://github.com/virt-manager/virt-manager
cd virt-manager
./virt-manager --debug

Comment 9 David Zampino 2017-06-01 21:33:59 UTC
Created attachment 1284249 [details]
Virt Manager Debug log 2

Comment 10 David Zampino 2017-06-01 21:34:57 UTC
I have attached the new logs. It automatically substituted the '\' for '5%C' and never authenticated, just hung on connecting

Comment 11 Cole Robinson 2017-06-01 22:08:55 UTC
Hmm that doesn't tell me much unfortunately. Does it work with virsh?

  virsh --connect qemu+ssh://mwat%5Cusername@kvmtest/system

Comment 12 David Zampino 2017-06-05 16:39:00 UTC
Virsh connects correctly in that format 'virsh --connect qemu+ssh://mwat%5Cusername@kvmtest/system' 

As an aside, I ssh in using by escaping the slash (e.g.) 'ssh mwat\\username@kvmtest'

Comment 13 Cole Robinson 2017-06-07 16:15:41 UTC
Hmm, so the hang happens at connection open time? Have you had virt-manager work with ssh without a \ in the name? If you use virt-manager --debug the password prompt will show up on virt-manager stdout, it won't launch an ssh password dialog (for a bunch of confusing technical reasons)

Comment 14 David Zampino 2017-06-09 20:19:02 UTC
Virt-manager has never worked with the sole exception of the 5%C you provided

Comment 15 Cole Robinson 2017-06-26 18:59:07 UTC
Sorry for the late response. Not sure what the issue is with this. With latest virt-manager code, can you

- add a new connection with the \ in the username
- add a new connection with the %5C in the username

verify that the %5C method works for opening the connection, and the plain virt-manager method fails/hangs or whatnot. Then provide the virt-manager --debug startup output

at startup, virt-manager will report the saved connection URIs, I want to compare them to see how they differ

Comment 16 David Zampino 2017-06-30 17:12:01 UTC
Created attachment 1293312 [details]
Test with \ and 5%C

Comment 17 David Zampino 2017-06-30 17:13:01 UTC
I have attached the --debug for the two test cases. I cloned virt-manager from github before running the test. The first test immediately throws and error, and the second one hangs up

Comment 18 Cole Robinson 2017-07-14 23:55:23 UTC
Can you reproduce those steps with this debugging patch applied to virt-manager.git, and post the new output:

diff --git a/virtinst/connection.py b/virtinst/connection.py
index d1f85c8c..686b7c6e 100644
--- a/virtinst/connection.py
+++ b/virtinst/connection.py
@@ -144,6 +144,7 @@ class VirtualConnection(object):
         authcb = self._auth_cb
         authcb_data = passwordcb
 
+        logging.debug("OPENAUTH: %s", self._open_uri)
         conn = libvirt.openAuth(self._open_uri,
                     [valid_auth_options, authcb,
                     (authcb_data, valid_auth_options)],

Comment 19 David Zampino 2017-07-27 21:52:51 UTC
Created attachment 1305660 [details]
Debug with connection.py debug code

Comment 20 David Zampino 2017-07-27 21:54:06 UTC
As for my most recent reply, I discovered the second test was hanging up because it was pointing to the wrong server, doh!

Comment 21 Cole Robinson 2017-08-06 21:09:15 UTC
Okay so it looks like the initial libvirt connection piece _is_ working, but there's still an issue with the graphical connection piece, not turning the %5C back into a \. However that's working for me with virt-manager git.

Your output shows you are running a virt-manager that's installed in the system (see if mentioning /usr/share at the beginning). Are you definitely running latest virt-manager.git? Make sure to 'git pull' to get the latest bits, then run ./virt-manager --debug   (the ./ at the beginning is critical)

Comment 22 David Zampino 2017-08-21 16:03:51 UTC
Created attachment 1316384 [details]
virt-manager debug logs 2017-8-21

Attached is the new log. I was able to both connect to host and connect to the VM, a first. Trying to delete the VM caused the application to crash however.

Comment 23 Cole Robinson 2017-08-26 01:34:15 UTC
Okay if you can connect to both the connection and the VM, I think this bug is fixed. If you can reliably reproduce the 'delete' issue, please file a separate bug


Note You need to log in before you can comment on or make changes to this bug.