block: Add support for Secure Shell (ssh) block device.
PATCH v4 1/1 block: Add support for Secure Shell (ssh) block device.
This is version 4 of the Secure Shell (ssh) block device.
Links to earlier versions:
v1: http://www.mail-archive.com/[email protected]/msg162605.html
v2: http://www.mail-archive.com/[email protected]/msg162730.html
v3: http://www.mail-archive.com/[email protected]/msg162805.html
The version supports:
- image creation, so eg. 'qemu-img create' can be used
- extending the file, so qcow2 works
- file.host, file.port, file.path, file.user properties (or ssh:// URLs)
- asynch read/write using coroutines
- ssh-agent authentication
- checks the remote host key against known_hosts
This version is robust and works for me reliably. Performance of linear reading (eg. qemu-img convert ssh://...) is very fast indeed. Random access performance is fairly poor (about the same as sshfs). However it's usable remotely for booting and running guests, even over relatively slow wifi links.
Rich.
PATCH v4 1/1 block: Add support for Secure Shell (ssh) block device.
From: "Richard W.M. Jones" <[email protected]>
qemu-system-x86_64 -drive file=ssh://hostname/some/image
QEMU will ssh into 'hostname' and open '/some/image' which is made available as a standard block device.
You can specify a username (ssh://user@host/...) and/or a port number (ssh://host:port/...). You can also use an alternate syntax using properties (file.user, file.host, file.port, file.path).
Current limitations:
- Authentication must be done without passwords or passphrases, using ssh-agent. Other authentication methods are not supported.
- Uses a single connection, instead of concurrent AIO with multiple SSH connections.
This is implemented using libssh2 on the client side. The server just requires a regular ssh daemon with sftp-server support. Most ssh daemons on Unix/Linux systems will work out of the box.
--- block/Makefile.objs | 1 + block/ssh.c | 878 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 47 +++ qemu-doc.texi | 40 +++ qemu-options.hx | 12 + 5 files changed, 978 insertions(+) create mode 100644 block/ssh.c
block/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ block-obj-$(CONFIG_LIBISCSI) += iscsi.o block-obj-$(CONFIG_CURL) += curl.o block-obj-$(CONFIG_RBD) += rbd.o block-obj-$(CONFIG_GLUSTERFS) += gluster.o +block-obj-$(CONFIG_LIBSSH2) += ssh.o endif common-obj-y += stream.o
block/ssh.c new file +878 -0
878 lines not on this page · raw message
configure +47 -0
83 lines not on this page · raw message
qemu-doc.texi +40 -0
@@ -423,6 +423,7 @@ snapshots. * disk_images_sheepdog:: Sheepdog disk images * disk_images_iscsi:: iSCSI LUNs * disk_images_gluster:: GlusterFS disk images +* disk_images_ssh:: Secure Shell (ssh) disk images @end menu @node disk_images_quickstart
@@ -1038,6 +1039,45 @@ qemu-system-x86_64 -drive file=gluster+unix:///testvol/dir/a.img?socket=/tmp/glu qemu-system-x86_64 -drive file=gluster+rdma://1.2.3.4:24007/testvol/a.img @end example +@node disk_images_ssh +@subsection Secure Shell (ssh) disk images + +You can access disk images located on a remote ssh server +by using the ssh protocol: + +@example +qemu-system-x86_64 -drive file=ssh://[@var{user}@@]@var{server}[:@var{port}]/@var{path} +@end example + +Alternative syntax using properties: + +@example +qemu-system-x86_64 -drive file.driver=ssh[,file.user=@var{user}],file.host=@var{server}[,file.port=@var{port}],file.path=@var{path} +@end example + +@var{ssh} is the protocol. + +@var{user} is the remote user. If not specified, then the local +username is tried. + +@var{server} specifies the remote ssh server. Any ssh server can be +used, but it must implement the sftp-server protocol. Most Unix/Linux +systems should work without requiring any extra configuration. + +@var{port} is the port number on which sshd is listening. By default +the standard ssh port (22) is used. + +@var{path} is the path to the disk image. + +Currently authentication must be done using ssh-agent. Other +authentication methods may be supported in future. + +Note: The ssh driver does not obey disk flush requests (ie. to commit +data to the backing disk when the guest requests it). This is because +the underlying protocol (SFTP) does not support this. Thus there is a +risk of guest disk corruption if the remote server or network goes +down during writes. + @node pcsys_network @section Network emulation
qemu-options.hx +12 -0
@@ -2106,6 +2106,18 @@ Example for Unix Domain Sockets qemu-system-i386 --drive file=nbd:unix:/tmp/nbd-socket @end example +@item SSH +QEMU supports SSH (Secure Shell) access to remote disks. + +Examples: +@example +qemu-system-i386 -drive file=ssh://user@@host/path/to/disk.img +qemu-system-i386 -drive file.driver=ssh,file.user=user,file.host=host,file.port=22,file.path=/path/to/disk.img +@end example + +Currently authentication must be done using ssh-agent. Other +authentication methods may be supported in future. + @item Sheepdog Sheepdog is a distributed storage system for QEMU. QEMU supports using either local sheepdog devices or remote networked
Signature · 1 line
1.8.1.4
Quoted 26 lines · Richard W.M. Jones
From: "Richard W.M. Jones" <[email protected]>
qemu-system-x86_64 -drive file=ssh://hostname/some/image
QEMU will ssh into 'hostname' and open '/some/image' which is made available as a standard block device.
You can specify a username (ssh://user@host/...) and/or a port number (ssh://host:port/...). You can also use an alternate syntax using properties (file.user, file.host, file.port, file.path).
Current limitations:
- Authentication must be done without passwords or passphrases, using ssh-agent. Other authentication methods are not supported.
- Uses a single connection, instead of concurrent AIO with multiple SSH connections.
This is implemented using libssh2 on the client side. The server just requires a regular ssh daemon with sftp-server support. Most ssh daemons on Unix/Linux systems will work out of the box.
Signed-off-by Richard W.M. Jones <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Kevin Wolf <[email protected]>
Quoted 8 lines
--- block/Makefile.objs | 1 + block/ssh.c | 878 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 47 +++ qemu-doc.texi | 40 +++ qemu-options.hx | 12 + 5 files changed, 978 insertions(+) create mode 100644 block/ssh.c
Please run qemu-iotests, see tests/qemu-iotests/check. For example, with NBD:
$ cd tests/qemu-iotests
$ QEMU_PROG=$HOME/qemu/x86_64-softmmu/qemu-system-x86_64 PATH=$HOME/qemu:$PATH \
./check -nbdA patch will be required to add -ssh support to ./check.
block/ssh.c line 106
Quoted 13 lines
block/ssh.c new file +13
-0+/* Wrappers around error_report which make sure to dump as much +* information from libssh2 as possible. +*/ +static void +session_error_report (BDRVSSHState *s,const char *fs, ...) +{ +va_list args; + +va_start (args, fs); + +if ((s)->session) { +char *ssh_err; +int ssh_err_len =sizeof ssh_err;
This variable is unused and initialization to sizeof ssh_err seems wrong. Please drop it and pass NULL to libssh2_session_last_error(3).
block/ssh.c line 117
Quoted 11 lines
block/ssh.c new file +11
-0+int ssh_err_code; + +libssh2_session_last_error ((s)->session, + &ssh_err, &ssh_err_len,0 ); +/* This is not an errno. See <libssh2.h>. */ + ssh_err_code =libssh2_session_last_errno ((s)->session); + +error_vprintf (fs, args); +error_printf (": %s (libssh2 error code: %d)" , ssh_err, ssh_err_code); + } +else {
QEMU tends to use } else { on a single line.
Review
Quoted 2 lines
(quoted diff) +2
-0+ error_vprintf(fs, args); + }
In fact this else statement can be avoided:
error_vprintf(fs, args);
if (s->session) {
...
error_printf(": %s (libssh2 error code: %d)", ssh_err, ssh_err_code);
}Quoted 22 lines
block/ssh.c new file +22
-0+ +va_end (args); +error_printf ("\n" ); +} + +static void +sftp_error_report (BDRVSSHState *s,const char *fs, ...) +{ +va_list args; + +va_start (args, fs); + +if ((s)->sftp) { +char *ssh_err; +int ssh_err_len =sizeof ssh_err; +int ssh_err_code; +unsigned long sftp_err_code; + +libssh2_session_last_error ((s)->session, + &ssh_err, &ssh_err_len,0 ); +/* This is not an errno. See <libssh2.h>. */ + ssh_err_code =libssh2_session_last_errno ((s)->session);
block/ssh.c line 151
Quoted 10 lines
block/ssh.c new file +10
-0+/* See <libssh2_sftp.h>. */ + sftp_err_code =libssh2_sftp_last_error ((s)->sftp); + +error_vprintf (fs, args); +error_printf (": %s (libssh2 error code: %d, sftp error code: %lu)" , + ssh_err, ssh_err_code, sftp_err_code); + } +else { +error_vprintf (fs, args); + }
Same comments apply to sftp_error_report().
Quoted 14 lines
block/ssh.c new file +14
-0+ +va_end (args); +error_printf ("\n" ); +} + +#ifndef _WIN32 +static const char *get_username (void ) +{ +struct passwd *pwd; + + pwd =getpwuid (geteuid ()); +if (!pwd) { +error_report ("failed to get current user name" ); +return NULL ;
block/ssh.c line 175
Quoted 10 lines
block/ssh.c new file +10
-0+ } +return pwd->pw_name; +} +#else +static const char *get_username (void ) +{ +error_report ("on Windows, specify a remote user name in the URI" ); +return NULL ; +} +#endif
This is ugly since it's platform-specific and uses getpwuid(3) which is not reentrant.
Does ssh(1) even use getpwuid(geteuid()) or does it check .ssh/config and then getenv("USER")? Perhaps we can just getenv("USER")?
Review
Quoted 2 lines
(quoted diff) +2
-0+ +static int parse_uri(const char *filename, QDict *options)
Use Error **errp argument instead of error_report()?
block/ssh.c line 180
Quoted 3 lines
block/ssh.c new file +3
-0+{ +URI *uri; +char *host =NULL ;
Unused variable.
Quoted 13 lines
block/ssh.c new file +13
-0+static int check_host_key (BDRVSSHState *s,const char *host,int port) +{ +int ret; +const char *home; +char *knh_file =NULL ; +LIBSSH2_KNOWNHOSTS *knh =NULL ; +const char *fingerprint; +size_t len; +int type; + + knh =libssh2_knownhost_init (s->session); +if (!knh) { + ret = -EINVAL ;
block/ssh.c line 262
Quoted 10 lines
block/ssh.c new file +10
-0+session_error_report (s,"failed to initialize known hosts support" ); + goto out; + } + + home =getenv ("HOME" ); +if (home) { + knh_file =g_strdup_printf ("%s/.ssh/known_hosts" , home); + }else { + knh_file =g_strdup_printf ("/root/.ssh/known_hosts" ); + }
Windows support?
Quoted 12 lines
block/ssh.c new file +12
-0+ +/* Read all known hosts from OpenSSH-style known_hosts file. */ +libssh2_knownhost_readfile (knh, knh_file,LIBSSH2_KNOWNHOST_FILE_OPENSSH ); + + fingerprint =libssh2_session_hostkey (s->session, &len, &type); +if (fingerprint) { +struct libssh2_knownhost *found; +int r; + + r = libssh2_knownhost_checkp(knh, host, port, fingerprint, len, + LIBSSH2_KNOWNHOST_TYPE_PLAIN| + LIBSSH2_KNOWNHOST_KEYENC_RAW,
block/ssh.c line 284
Quoted 10 lines
block/ssh.c new file +10
-0+ &found); +switch (r) { +case LIBSSH2_KNOWNHOST_CHECK_MATCH : +/* OK */ +DPRINTF ("host key OK: %s" , found->key); +break ; +case LIBSSH2_KNOWNHOST_CHECK_MISMATCH : + ret = -EINVAL ; +session_error_report (s,"host key does not match the one in known_hosts (found key %s)" , + found->key);
Does the user know the offending known_hosts line? ssh(1) normally says something like "Mismatch with line ~/.ssh/known_hosts:35" so you know which hostkey to drop if you wish to proceed.
block/ssh.c line 289
Quoted 5 lines
block/ssh.c new file +5
-0+ goto out; +case LIBSSH2_KNOWNHOST_CHECK_NOTFOUND : + ret = -EINVAL ; +session_error_report (s,"no host key was found in known_hosts" ); + goto out;
ssh(1) prompts the user to accept the hostkey. When QEMU fails like this the user needs to run ssh(1) first to populate known_hosts?
configure echo " --disable-glusterfs disable GlusterFS backend" · line 1174
Quoted 5 lines
configure +1
-0@@ -1166,6 +1171,7 @@ echo " --disable-glusterfs disable GlusterFS backend" echo " --enable-gcov enable test coverage analysis with gcov" echo " --gcov=GCOV use specified gcov [$gcov_tool]" echo " --enable-tpm enable TPM support" +echo " --enable-libssh2 enable ssh block device support"
Most options seem to also document --disable-FOO. Please do that.
Quoted 2 lines · Stefan Hajnoczi
ssh(1) prompts the user to accept the hostkey. When QEMU fails like this the user needs to run ssh(1) first to populate
known_hosts?
Yes - I tested this and qemu will simply fail to open the disk with the error message about the host key not being found. Currently you have to manually log in (eg. with ssh), accept the key in ssh, and then retry the qemu command.
Not that I think this is much of a problem, as long as the error is clear.
But ... if I wanted to make qemu interactively ask about host keys, or even accept passwords, how would I do that? Is there a block device driver that asks for passwords that I can look at?
[The only mention of 'password' is in the iscsi driver, and that seems to be related to passing passwords in the URL (!?!)]
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Quoted 12 lines · Richard W.M. Jones
Quoted 2 lines · Stefan Hajnoczi
ssh(1) prompts the user to accept the hostkey. When QEMU fails like this the user needs to run ssh(1) first to populate
known_hosts?Yes - I tested this and qemu will simply fail to open the disk with the error message about the host key not being found. Currently you have to manually log in (eg. with ssh), accept the key in ssh, and then retry the qemu command.
Not that I think this is much of a problem, as long as the error is clear.
Quoted 6 lines
But ... if I wanted to make qemu interactively ask about host keys, or even accept passwords, how would I do that? Is there a block device driver that asks for passwords that I can look at?
[The only mention of 'password' is in the iscsi driver, and that seems to be related to passing passwords in the URL (!?!)]
There is an API to prompt for a image encryption key, see .bdrv_set_key().
Stefan
Quoted 1 line · Stefan Hajnoczi
On Wed, Mar 27, 2013 at 03:57:29PM +0000, Richard W.M. Jones wrote:
[...]
Thanks for reviewing this patch. I will post an updated v5 on this list soon, but I also have some comments (below).
Quoted 8 lines
Please run qemu-iotests, see tests/qemu-iotests/check. For example, with NBD:
$ cd tests/qemu-iotests $ QEMU_PROG=$HOME/qemu/x86_64-softmmu/qemu-system-x86_64 PATH=$HOME/qemu:$PATH \ ./check -nbdA patch will be required to add -ssh support to ./check.
I have added this in the updated patch.
A question: Are the -qcow2 tests meant to pass? Many don't pass for my ssh driver (ie. './check -ssh -qcow2'). I tried using the nbd driver (ie. './check -nbd -qcow2') and a large number of those fail as well. To take an example, test 013 fails because it tries to run the 'mv' command on the nbd: URL (or the ssh: URL when running the test on my block driver). It looks like this and other qcow2 tests are a bit broken on anything other than plain files.
[...]
Quoted 2 lines
Does ssh(1) even use getpwuid(geteuid()) or does it check .ssh/config and then
getenv("USER")? Perhaps we can justgetenv("USER")?
ssh uses getpwuid too.
The updated patch adds some thread-safe code to osdep.c, but still doesn't work on Windows.
Quoted 8 lines
block/ssh.c line 262
Quoted 6 lines
block/ssh.c new file +6
-0+ home =getenv ("HOME" ); +if (home) { + knh_file =g_strdup_printf ("%s/.ssh/known_hosts" , home); + }else { + knh_file =g_strdup_printf ("/root/.ssh/known_hosts" ); + }Windows support?
I have no idea what Windows does for this, so I punted on the problem.
Quoted 8 lines
block/ssh.c line 284
Quoted 4 lines
block/ssh.c new file +4
-0+case LIBSSH2_KNOWNHOST_CHECK_MISMATCH : + ret = -EINVAL ; +session_error_report (s,"host key does not match the one in known_hosts (found key %s)" , + found->key);Does the user know the offending
known_hostsline? ssh(1) normally says something like "Mismatch with line ~/.ssh/known_hosts:35" so you know which hostkey to drop if you wish to proceed.
Unfortunately it doesn't appear that libssh2 keeps the original line number around.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Quoted 13 lines · Richard W.M. Jones
Quoted 9 lines · Stefan Hajnoczi
On Wed, Mar 27, 2013 at 03:57:29PM +0000, Richard W.M. Jones wrote:
Please run qemu-iotests, see tests/qemu-iotests/check. For example, with NBD:$ cd tests/qemu-iotests $ QEMU_PROG=$HOME/qemu/x86_64-softmmu/qemu-system-x86_64 PATH=$HOME/qemu:$PATH \ ./check -nbdA patch will be required to add -ssh support to ./check.
I have added this in the updated patch.
Quoted 7 lines
A question: Are the -qcow2 tests meant to pass? Many don't pass for my ssh driver (ie. './check -ssh -qcow2'). I tried using the nbd driver (ie. './check -nbd -qcow2') and a large number of those fail as well. To take an example, test 013 fails because it tries to run the 'mv' command on the nbd: URL (or the ssh: URL when running the test on my block driver). It looks like this and other qcow2 tests are a bit broken on anything other than plain files.
Yes, I don't expect qemu-iotests to work with qcow2-on-nbd.
Just ./check -nbd and ./check -ssh should work.
Stefan
Quoted 1 line · Stefan Hajnoczi
Just ./check -nbd and ./check -ssh should work.
Both work 100% for me (with patch v7).
Rich.
Signature · 3 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
More specifically, here's the output on my machine:
rjones@choo:~/d/qemu/tests/qemu-iotests$ QEMU_PROG=~/d/qemu/x86_64-softmmu/qemu-system-x86_64 PATH=~/d/qemu:$PATH ./check -ssh QEMU -- /home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64 QEMU_IMG -- /home/rjones/d/qemu/qemu-img QEMU_IO -- /home/rjones/d/qemu/qemu-io IMGFMT -- raw IMGPROTO -- ssh PLATFORM -- Linux/x86_64 choo 3.7.2-204.fc18.x86_64
001 7s ...
002 11s ...
003 11s ...
004 19s ...
005 4s ...
006 [not run] not suitable for this image format: raw
007 18s ... [not run] not suitable for this image format: raw
008 8s ...
009 3s ...
010 4s ...
011 17s ...
012 [not run] not suitable for this image protocol: ssh
013 [not run] not suitable for this image format: raw
014 [not run] not suitable for this image format: raw
015 53s ... [not run] not suitable for this image format: raw
016 [not run] not suitable for this image protocol: ssh
017 [not run] not suitable for this image format: raw
018 [not run] not suitable for this image format: raw
019 [not run] not suitable for this image format: raw
020 [not run] not suitable for this image format: raw
021 48s ...
022 37s ... [not run] not suitable for this image format: raw
023 [not run] not suitable for this image format: raw
024 [not run] not suitable for this image format: raw
025 [not run] not suitable for this image protocol: ssh
026 [not run] not suitable for this image format: raw
027 7s ... [not run] not suitable for this image format: raw
028 [not run] not suitable for this image format: raw
029 10s ... [not run] not suitable for this image format: raw
030 [not run] not suitable for this image format: raw
031 [not run] not suitable for this image format: raw
032 5s ...
033 14s ...
034 [not run] not suitable for this image format: raw
035 3s ... [not run] not suitable for this image format: raw
036 [not run] not suitable for this image format: raw
037 [not run] not suitable for this image format: raw
038 [not run] not suitable for this image format: raw
039 [not run] not suitable for this image format: raw
040 10s ... [not run] not suitable for this image format: raw
041 20s ... [not run] not suitable for this image format: raw
042 [not run] not suitable for this image format: raw
043 [not run] not suitable for this image format: raw
044 29s ... [not run] not suitable for this image format: raw
045 1s ...
046 [not run] not suitable for this image format: raw
047 2s ... [not run] not suitable for this image format: raw
048 [not run] not suitable for this image protocol: ssh
049 [not run] not suitable for this image format: raw
050 [not run] not suitable for this image format: raw
052 13s ...
Not run: 006 007 012 013 014 015 016 017 018 019 020 022 023 024 025 026 027 028 029 030 031 034 035 036 037 038 039 040 041 042 043 044 046 047 048 049 050 Passed all 14 tests
Rich.
Signature · 3 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
Quoted 3 lines · Richard W.M. Jones
More specifically, here's the output on my machine:
rjones@choo:~/d/qemu/tests/qemu-iotests$ QEMU_PROG=~/d/qemu/x86_64-softmmu/qemu-system-x86_64 PATH=~/d/qemu:$PATH ./check -ssh
gah, I just hit a libssh2 limitation. In my .ssh/config I have:
NoHostAuthenticationForLocalhost yes
This stops ssh from complaining when I hope to another host through an ssh tunnel (the host key wouldn't match localhost).
$ ssh localhost ...works fine... $ ./qemu-img info ssh://localhost/home/stefanha/qemu/test.img no host key was found in known_hosts: (libssh2 error code: 0) qemu-img: Could not open 'ssh://localhost/home/stefanha/qemu/test.img': Invalid argument
Quoted 1 line
From what I can see libssh2 does not support loading .ssh/config.
This is a limitation not just for NoHostAuthenticationForLocalhost but also for all the Hostname aliases with User options that I have in my .ssh/config - I can't use them. I remember the Fabric tool had similar issues, it uses Python paramiko ssh implementation, and I think they added to code to parse .ssh/config so all these conveniences work:
https://github.com/paramiko/paramiko/blob/master/paramiko/config.py
What do you think?
Stefan
Quoted 2 lines · Stefan Hajnoczi
On Mon, Apr 8, 2013 at 3:05 PM, Richard W.M. Jones <[email protected]> wrote:
From what I can see libssh2 does not support loading .ssh/config.
I was told that sshfs *does* handle .ssh/config. Turns out that sshfs spawns "ssh -s sftp" to get a SFTP subsystem channel. Then it directly implements the SFTP application protocol.
This way they don't need to link against libssh2. They spawn ssh with a socketpair on stdin/stdout. They send/receive SFTP messages directly.
The benefit is that everything works (options, host key handling, and configuration files) like you'd expect from ssh/sftp/scp.
You may be tired of trying different alternatives, but perhaps switching to this model is worth it. It would solve these integration/user friendliness issues that a libssh2 implementation has.
Stefan
Quoted 11 lines · Stefan Hajnoczi
Quoted 2 lines · Stefan Hajnoczi
On Mon, Apr 8, 2013 at 3:05 PM, Richard W.M. Jones <[email protected]> wrote:
From what I can see libssh2 does not support loading .ssh/config.I was told that sshfs *does* handle .ssh/config. Turns out that sshfs spawns "ssh -s sftp" to get a SFTP subsystem channel. Then it directly implements the SFTP application protocol.
This way they don't need to link against libssh2. They spawn ssh with a socketpair on stdin/stdout. They send/receive SFTP messages directly.
Indeed, as I mentioned in an earlier message, sshfs implements the complete SFTP stack itself and uses an external ssh process.
It's up to 5 times as much code to do so:
sshfs-fuse-2.4$ wc -l *.c
589 cache.c
3930 sshfs.c
18 sshnodelay.c
4537 total
qemu/block$ wc -l ssh.c
914 ssh.c
I don't think having an entire SFTP stack inside qemu would help.
Quoted 5 lines
I just hit a libssh2 limitation. In my .ssh/config I have:
NoHostAuthenticationForLocalhost yesThis stops ssh from complaining when I hope to another host through an ssh tunnel (the host key wouldn't match localhost).
I'm using the ssh configuration attached for tunnelling through another host. It doesn't require toggling 'NoHostAuthenticationForLocalhost', and so is safer because it still does host key checking.
I think a better and simpler way to solve this is simply to allow URLs like:
ssh://localhost/path?host_key_check=no
which is the same as NoHostAuthenticationForLocalhost (ie don't do any host checking on this connection).
Even better would be to let people specify the key:
ssh://localhost/path?host_key_check=aa:bb:cc:dd:ee:ff
This means that management applications can parse .ssh/config if they feel like doing that.
Rich.
----------------------------------------------------------------------
My ssh tunnelling configuration:
Host tunnelled-host
PreferredAuthentications publickey,keyboard-interactive,password ProxyCommand ssh -T -o ForwardAgent=yes proxy nc %h %p
Host proxy
HostName proxy.example.com
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Quoted 24 lines · Richard W.M. Jones
Quoted 11 lines · Stefan Hajnoczi
Quoted 2 lines · Stefan Hajnoczi
On Mon, Apr 8, 2013 at 3:05 PM, Richard W.M. Jones <[email protected]> wrote:
From what I can see libssh2 does not support loading .ssh/config.I was told that sshfs *does* handle .ssh/config. Turns out that sshfs spawns "ssh -s sftp" to get a SFTP subsystem channel. Then it directly implements the SFTP application protocol.
This way they don't need to link against libssh2. They spawn ssh with a socketpair on stdin/stdout. They send/receive SFTP messages directly.
Indeed, as I mentioned in an earlier message, sshfs implements the complete SFTP stack itself and uses an external ssh process.
It's up to 5 times as much code to do so:
sshfs-fuse-2.4$ wc -l *.c
589cache.c
3930sshfs.c
18sshnodelay.c
4537 total
Quoted 4 lines
qemu/block$ wc -l
ssh.c
914ssh.cI don't think having an entire SFTP stack inside qemu would help.
How many SFTP messages do you need? Probably just a handfull (read, write, fsync, open, close).
sshfs does way more than just that. It implements the entire FUSE VFS interface and a cache. So I think the lines of code comparison isn't apples to apples.
The more practical reason for not spawning an external ssh process would be that QEMU is increasingly being jailed and handed only file descriptors. This works well for a TCP socket but is messier if the management stack has to launch SSH on behalf of QEMU first before handing the socketpair.
Anyway, the reason I like the external ssh process approach is that we get all the standard hostkey and configuration file handling. Usability is important, if the integration has too many rough edges, people will not use the block driver.
Quoted 10 lines
Quoted 5 lines
I just hit a libssh2 limitation. In my .ssh/config I have:
NoHostAuthenticationForLocalhost yesThis stops ssh from complaining when I hope to another host through an ssh tunnel (the host key wouldn't match localhost).
I'm using the ssh configuration attached for tunnelling through another host. It doesn't require toggling 'NoHostAuthenticationForLocalhost', and so is safer because it still does host key checking.
Cool, thanks for sharing that.
Quoted 8 lines
I think a better and simpler way to solve this is simply to allow URLs like:
ssh://localhost/path?host_key_check=no
which is the same as NoHostAuthenticationForLocalhost (ie don't do any host checking on this connection).
Quoted 6 lines
Even better would be to let people specify the key:
ssh://localhost/path?host_key_check=aa:bb:cc:dd:ee:ff
This means that management applications can parse .ssh/config if they feel like doing that.
These are steps in the right direction of making -drive ssh:// easy to use.
Stefan