Skip to content

Instantly share code, notes, and snippets.

@BrianRossmajer
Created December 26, 2017 14:48
Show Gist options
  • Save BrianRossmajer/e82e9944d2b246587be4baa9aeac3b98 to your computer and use it in GitHub Desktop.
Save BrianRossmajer/e82e9944d2b246587be4baa9aeac3b98 to your computer and use it in GitHub Desktop.
Using sshfs high-speed no-encryption
http://pl.atyp.us/wordpress/index.php/2009/09/file-transfer-fun/
File Transfer Fun
17 September, 2009 8:32 am
I’ve written before about the extreme usefulness of sshfs for accessing files remotely without having to install server software. It continues to be an important part of my toolbox, as does its cousin CurlFtpFS which – unlike sshfs – I can even use to mount a directory here on my web host. Of course, either becomes even more useful when combined with some easy method of synchronization. You probably have rsync already. You can also use Unison if you need bidirectional synchronization – which you generally will if you’re trying to use a single directory somewhere as a “drop box” to share between multiple machines.
I just found another sshfs trick today. If the connection between your two machines is already secure – e.g. on the same private network or connected via a secure VPN/tunnel – you might want to avoid an extra round of encryption and decryption by using the “-o directport” option to sshfs. This causes sshfs to bypass all of the ssh stuff and just create a simple TCP connection . . . but what should you run at the other end? Here’s where socat (another extra-useful tool) comes in handy. On the server end (assuming a pretty standard Linux setup), you can just run this:
socat TCP4-LISTEN:7777 EXEC:/usr/lib/sftp-server
Then, on the client:
sshfs -o directport=7777 remote:/dir /local/dir
Now you have a completely insecure TCP between the two machines, so you’d really better not do this directly over the internet without some other way of securing things at a lower level. It’s still pretty handy, though, and I couldn’t find a mention anywhere else of how to do it so there it is.
Author: Jeff Darcy
Filed under: tech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment