Wangkai (Kevin,C)
2013-Apr-11 09:45 UTC
[libvirt-users] How can I open a libvirt remote connection with ssh
Hi, When I use 'virConnectOpenAuth' function to connect to '192.168.1.102' libvirtd with ssh, Code below, the screen print the dialog "root at 192.168.1.102's password:" , and only After I type the password, the connection can be created. How can I connect to libvirtd with ssh automatically? No need to type the password manually. char *au[2] = {"root", "xxxx"}; virConnectAuth auth = { credTypes, sizeof(credTypes) / sizeof(int), virConnCb,/* callback function, actually was not be called after connect*/ au /* user and password */ }; conn = virConnectOpenAuth("qemu+ssh://192.168.1.102/system", &auth, 0); Thanks, Kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20130411/10a9246b/attachment.htm>
Daniel P. Berrange
2013-Apr-11 09:54 UTC
[libvirt-users] How can I open a libvirt remote connection with ssh
On Thu, Apr 11, 2013 at 09:45:18AM +0000, Wangkai (Kevin,C) wrote:> Hi, > > When I use 'virConnectOpenAuth' function to connect to '192.168.1.102' libvirtd with ssh, > Code below, the screen print the dialog "root at 192.168.1.102's password:" , and only > After I type the password, the connection can be created.Libvirt has to spawn an external SSH process for +ssh URIs, so we can't hook it up into our auth callbacks.> How can I connect to libvirtd with ssh automatically? No need to type the password manually.You need to setup SSH public keys + SSH agent> > char *au[2] = {"root", "xxxx"}; > virConnectAuth auth = { > credTypes, > sizeof(credTypes) / sizeof(int), > virConnCb,/* callback function, actually was not be called after connect*/ > au /* user and password */ > }; > conn = virConnectOpenAuth("qemu+ssh://192.168.1.102/system", &auth, 0);virConnectOpenAuth() doesn't do anything useful for '+ssh' URIs. There is however a alternative 'libssh2' URI that does use the callbacks. eg qemu+libssh2://hostname/system This is less tested & potentially buggy, but it might be ok for your needs Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Henrik Ahlgren
2013-Apr-11 10:01 UTC
[libvirt-users] How can I open a libvirt remote connection with ssh
On Thu, Apr 11, 2013 at 09:45:18AM +0000, Wangkai (Kevin,C) wrote:> > How can I connect to libvirtd with ssh automatically? No need to type the password manually.Just use SSH public key authentication with an empty passphrase, just as you would with any other automated SSH connection.
Seemingly Similar Threads
- reboot command lost?
- [PATCH] libvirt-auth: Provide a friendlier wrapper around virConnectAuthPtrDefault (RHBZ#1044014).
- [PATCH] New APIs: Model libvirt authentication events through the API.
- vhost-net requested but could not be initialized
- Re: vhost-net requested but could not be initialized