ssh: switch from libssh2 to libssh
PATCH v2 1/1 ssh: switch from libssh2 to libssh
Rewrite the implementation of the ssh block driver to use libssh instead of libssh2. The libssh library has various advantages over libssh2:
- easier API for authentication (for example for using ssh-agent)
- easier API for known_hosts handling
- supports newer types of keys in known_hosts
Kerberos authentication can be enabled once the libssh bug for it [1] is fixed.
The development version of libssh (i.e. the future 0.8.x) supports fsync, so reuse the build time check for this.
[1] https://red.libssh.org/issues/242
---
Changes from v1:
- fixed jumbo packets writing
- fixed missing 'err' assignment
- fixed commit message
block/Makefile.objs | 6 +- block/ssh.c | 551 +++++++++++++++++++++------------------------------- configure | 65 +++---- 3 files changed, 256 insertions(+), 366 deletions(-)
block/Makefile.objs +3 -3
@@ -19,7 +19,7 @@ block-obj-$(CONFIG_CURL) += curl.o block-obj-$(CONFIG_RBD) += rbd.o block-obj-$(CONFIG_GLUSTERFS) += gluster.o block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o -block-obj-$(CONFIG_LIBSSH2) += ssh.o +block-obj-$(CONFIG_LIBSSH) += ssh.o block-obj-y += accounting.o dirty-bitmap.o block-obj-y += write-threshold.o block-obj-y += backup.o
@@ -38,8 +38,8 @@ rbd.o-cflags := $(RBD_CFLAGS) rbd.o-libs := $(RBD_LIBS) gluster.o-cflags := $(GLUSTERFS_CFLAGS) gluster.o-libs := $(GLUSTERFS_LIBS) -ssh.o-cflags := $(LIBSSH2_CFLAGS) -ssh.o-libs := $(LIBSSH2_LIBS) +ssh.o-cflags := $(LIBSSH_CFLAGS) +ssh.o-libs := $(LIBSSH_LIBS) archipelago.o-libs := $(ARCHIPELAGO_LIBS) block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o dmg-bz2.o-libs := $(BZIP2_LIBS)
block/ssh.c +221 -330
909 lines not on this page · raw message
configure +32 -33
115 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 8 lines · Pino Toscano
Rewrite the implementation of the ssh block driver to use libssh instead of libssh2. The libssh library has various advantages over libssh2:
- easier API for authentication (for example for using ssh-agent)
- easier API forknown_hostshandling
- supports newer types of keys inknown_hostsKerberos authentication can be enabled once the libssh bug for it [1] is fixed.
IIUC from the code this relies on QEMU being able to talk to an ssh agent to do public key auth. Is there a way to directly provide the passphase for the private key (avoiding need for an agent), or to provide a plani password to libssh ?
If so, you could use the QEMU 'secret' object type to provide these passphrases & passwords to QEMU, which can in turn pass them to libssh.
Avoiding the need for ssh agent in this way would make it possible to use this driver with libvirt in more circumstances.
eg for plain passwords you could do
$QEMU -object secret,id=sec0,data=mypassword
-drive driver=ssh,....,password-secret=sec0
while for private key passphrases
$QEMU -object secret,id=sec0,data=mypassphrase
-drive driver=ssh,....,key-passphrase-secret=sec0
No need to do this all as part of this patch though - it'd be cleaner to do this as a separate patch
Regards,
Daniel
Signature · 3 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Quoted 14 lines · Pino Toscano
Rewrite the implementation of the ssh block driver to use libssh instead of libssh2. The libssh library has various advantages over libssh2:
- easier API for authentication (for example for using ssh-agent)
- easier API forknown_hostshandling
- supports newer types of keys inknown_hostsKerberos authentication can be enabled once the libssh bug for it [1] is fixed.
The development version of libssh (i.e. the future 0.8.x) supports fsync, so reuse the build time check for this.
Quoted 7 lines
Signed-off-by Pino Toscano <[email protected]>---
Changes from v1:
- fixed jumbo packets writing
- fixed missing 'err' assignment
- fixed commit message
This version works, but I also switched from using a remote server to using this over localhost.
It seems as if the timeout might be a bit short. Could that be made controllable? Or increased to match whatever libssh2 was using?
I couldn't see any other problems in the patch itself. knownhost and ssh-agent handling certainly seems much simpler :-)
Before I forget, there's another problem we found with the old ssh
driver: It cannot open a device on the remote side, eg. if you used:
`file.driver=ssh,file.path=/dev/sdX' I suspect this is not solvable on the client side, it requires changes to sshd.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Quoted 7 lines · On Friday, 21 October 2016 12:25:40 CEST Daniel P. Berrange wrote:
Quoted 6 lines · Pino Toscano
Rewrite the implementation of the ssh block driver to use libssh instead of libssh2. The libssh library has various advantages over libssh2:
- easier API for authentication (for example for using ssh-agent)
- easier API forknown_hostshandling
- supports newer types of keys inknown_hosts
Quoted 7 lines
Quoted 2 lines
Kerberos authentication can be enabled once the libssh bug for it [1] is fixed.
IIUC from the code this relies on QEMU being able to talk to an ssh agent to do public key auth. Is there a way to directly provide the passphase for the private key (avoiding need for an agent), or to provide a plani password to libssh ?
Yes, both are supported by libssh.
Quoted 12 lines
If so, you could use the QEMU 'secret' object type to provide these passphrases & passwords to QEMU, which can in turn pass them to libssh.
Avoiding the need for ssh agent in this way would make it possible to use this driver with libvirt in more circumstances.
eg for plain passwords you could do
$QEMU -object secret,id=sec0,data=mypassword
-drive driver=ssh,....,password-secret=sec0
Quoted 8 lines
while for private key passphrases
$QEMU -object secret,id=sec0,data=mypassphrase
-drive driver=ssh,....,key-passphrase-secret=sec0No need to do this all as part of this patch though - it'd be cleaner to do this as a separate patch
Right, good idea.
Thanks,
Signature · 1 line
Pino Toscano
Quoted 18 lines · On Friday, 21 October 2016 13:02:21 CEST Richard W.M. Jones wrote:
Quoted 17 lines · Pino Toscano
Rewrite the implementation of the ssh block driver to use libssh instead of libssh2. The libssh library has various advantages over libssh2:
- easier API for authentication (for example for using ssh-agent)
- easier API forknown_hostshandling
- supports newer types of keys inknown_hostsKerberos authentication can be enabled once the libssh bug for it [1] is fixed.
The development version of libssh (i.e. the future 0.8.x) supports fsync, so reuse the build time check for this.
[1] https://red.libssh.org/issues/242
Signed-off-by Pino Toscano <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Changes from v1:
- fixed jumbo packets writing
- fixed missing 'err' assignment
- fixed commit messageThis version works, but I also switched from using a remote server to using this over localhost.
Could you please give it a try with the remote server case as well?
Quoted 2 lines
It seems as if the timeout might be a bit short. Could that be made controllable? Or increased to match whatever libssh2 was using?
Which timeout are you referring to?
Thanks,
Signature · 1 line
Pino Toscano
Quoted 24 lines · Pino Toscano
Quoted 23 lines · On Friday, 21 October 2016 13:02:21 CEST Richard W.M. Jones wrote:
Quoted 21 lines · Pino Toscano
Rewrite the implementation of the ssh block driver to use libssh instead of libssh2. The libssh library has various advantages over libssh2:
- easier API for authentication (for example for using ssh-agent)
- easier API forknown_hostshandling
- supports newer types of keys inknown_hostsKerberos authentication can be enabled once the libssh bug for it [1] is fixed.
The development version of libssh (i.e. the future 0.8.x) supports fsync, so reuse the build time check for this.
[1] https://red.libssh.org/issues/242
Signed-off-by Pino Toscano <[email protected]>---
Changes from v1:
- fixed jumbo packets writing
- fixed missing 'err' assignment
- fixed commit message
Quoted 4 lines
Quoted 2 lines
This version works, but I also switched from using a remote server to using this over localhost.
Could you please give it a try with the remote server case as well?
I tried it and it failed with the remote server. Same kinds of errors as last time.
Quoted 4 lines
Quoted 2 lines
It seems as if the timeout might be a bit short. Could that be made controllable? Or increased to match whatever libssh2 was using?
Which timeout are you referring to?
Not any particular thing, I just observed that with the remote server the errors happen quite quickly, and so perhaps there is a shorter timeout. (libssh2 apparently defaults to unlimited waiting, although I'm sure there are other timeouts in ssh or TCP which kick in).)
Rich.
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW