Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 4 additions & 0 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading