From 113882adda259e7019abbd0865c6b8b58676fa26 Mon Sep 17 00:00:00 2001 From: h4sh5 Date: Tue, 11 Nov 2025 16:30:19 +1000 Subject: [PATCH 1/2] ipv6 support for directport connection --- sshfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sshfs.c b/sshfs.c index 676fd586..4abaf63b 100644 --- a/sshfs.c +++ b/sshfs.c @@ -1258,6 +1258,10 @@ static int connect_to(struct conn *conn, char *host, char *port) memset(&hint, 0, sizeof(hint)); hint.ai_family = PF_INET; + if (strstr(host, ":") != NULL) { // only ipv6 should have : in it, normal IP and domains do not. + hint.ai_family = PF_INET6; + DEBUG("using ipv6 to connect to host %s\n", host); + } hint.ai_socktype = SOCK_STREAM; err = getaddrinfo(host, port, &hint, &ai); if (err) { From 882d3a018506f795864b49abab92b48fdbcbee99 Mon Sep 17 00:00:00 2001 From: h4sh5 Date: Tue, 11 Nov 2025 17:53:52 +1000 Subject: [PATCH 2/2] add documentation on bypassing SSH --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 02097134..1940a8aa 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,39 @@ On BSD and macOS, to unmount the filesystem: umount mountpoint ``` +### Bypassing SSH + +#### Using directport + +Using direct connections to sftp-server to bypass SSH for performance is also possible. To do this, start a network service using sftp-server (part of OpenSSH) on a server, then connect directly using `-o directport=PORT` option. + +On server (listen on port 1234 using socat): + +`socat tcp-listen:1234,reuseaddr,fork exec:/usr/lib/openssh/sftp-server` + +On client: + +`sshfs -o directport=1234 127.0.0.1:/tmp /tmp/mnt` + +Note that this is insecure as connection will happen without encryption. Only use this on localhost or trusted networks. This option is sometimes used by other projects to mount folders inside VMs. + +IPv6 is also possible: + +`socat tcp6-listen:1234,reuseaddr,fork exec:/usr/lib/openssh/sftp-server` + +`sshfs -o directport=1234 [::1]:/tmp /tmp/mnt` + +#### Using vsock + +Similarly to above, Linux [vsock](https://man7.org/linux/man-pages/man7/vsock.7.html) can be used to connect directly to sockets within VMs using `-o vsock=CID:PORT`. + +``` +# on the host +socat VSOCK-LISTEN:12345 EXEC:"/usr/lib/openssh/sftp-server",nofork +# on the clientside +sshfs -o vsock=2:12345 unused_host: ./tmp +``` + ## Installation