r/linuxquestions • • Dec 25 '20

Tip of the hat - sshfs

Just a tip of the hat to linux. The more I learn about Linux, the more I realize it is the OS that can do anything you can throw at it. Anything you can think of, someone has already done. Once you get a feel for how it drives, the syntax even begins to look familiar.

I was tinkering about late last night and after transferring some files over SCP I found myself wondering, could I just make that remote home directory sub folder available at all times? Sure enough sshfs.

I quickly discovered I can mount remote directories locally over ssh with sshfs.

sshfs user@remote:/remote/directory /localmount/directory -o IdentityFile=/pathto/sshkeys

Well done again Linux.

148 Upvotes

34 comments sorted by

28

u/Serialtorrenter Dec 25 '20

On some rooted Android devices, there is a working port of sshfs. I find this immensely useful. For those interested, it is in the Play Store and called EasySSHFS, and it's by not_w.

9

u/thexavier666 Dec 25 '20

EasySSHFS

Wait, with this I can have a mounted directory on my phone which will look local to my android apps. Is this correct?

3

u/Serialtorrenter Dec 25 '20

It really depends on the app. AFAIK, you can't mount to a directory inside the shared storage partition. If the app supports browsing its private directory, you can mount to there and then browse that.

2

u/Twist36 Dec 25 '20

It's not the same, but samsung recently added support for sftp in their files app. It's been very useful so far.

13

u/spryfigure Dec 25 '20

Use with sshfs -o ciphers=aes128-ctr in your intranet at home for best use of resources. You could also try arcfour instead of aes128-ctr, but I think the latter is better supported (arcfour doesn't work for me).

3

u/Sophira Dec 25 '20

What do you mean by "best use of resources"?

12

u/WhAtEvErYoUmEaN101 Dec 25 '20

Probably faster encryption at the expense of security

3

u/kevdogger Dec 25 '20

Just curious...what are the most secure ciphers or let's just say high grade ciphers?

4

u/DoctorWorm_ Dec 25 '20

I believe chacha is the leading technologies these days, but you should always follow your encryption library's instructions.

Wireguard is pretty state of the art, encryption-wise, so check that out if you're interested.

2

u/spryfigure Dec 25 '20

The ones ssh uses by default, so no need to worry. A quick google about 'ssh speeds' gives you a ton of related information.

1

u/WhAtEvErYoUmEaN101 Dec 25 '20

I'll try to not answer this directly since I'm no security expert and any answer could bring huge repercussions with it, but Mozilla's OpenSSL cipher list is a good starting point

6

u/spryfigure Dec 25 '20

ArcFour and AES128-CTR are weak crypto algorithms which use very little CPU, AES128-CTR often is wired in the CPU to use even less. You shouldn't use them over the internet, but for home usage, they are OK.

Your sshfs will be faster, more responsive and use less CPU and power.

1

u/Atralb Dec 25 '20 edited Dec 26 '20

If you're considering this, why even bother encrypting your intranet connections ?

1

u/7h3w1zz Dec 26 '20

OpenSSH, at least, doesn't have an unencrypted option without a recompile. There's a Stack Exchange Question with info.

As for "why not use something other than ssh?" It's pretty convenient and ubiquitous. :shrug:

1

u/Atralb Dec 26 '20

OpenSSH, at least, doesn't have an unencrypted option without a recompile

Ah right thx ! Not near my pc now.

Indeed, it does make sense given this fact.

0

u/spryfigure Dec 25 '20

Because a lot of people don't care about the 'encryption' part, only for the 'ease of remote use or copy' part?

0

u/Atralb Dec 25 '20

Because a lot of people don't care about the 'encryption' part, only for the 'ease of remote use or copy' part?

I don't think you understood my comment. That's exactly what I'm saying.

5

u/[deleted] Dec 25 '20

I felt the same way when I discovered sshfs years ago. Recommend /r/selfhosted too, lots of Linux geeks hang out there and cool tips can be learned.

3

u/2cats2hats Dec 25 '20

Once you get a feel for how it drives, the syntax even begins to look familiar.

It sure does, gets more interesting to see how vast the modularity of linux is.

-10

u/Barafu Dec 25 '20
  1. SCP is abandoned, use rsync instead.

  2. sshfs is great for quick or secondary connections, but keep in mind that it uses way more resources than SMB or NFS, which in turn use more resources than dedicated remote filesystems.

19

u/happymellon Dec 25 '20

The last I had read, scp was no longer the scp that was abandoned but was being rewritten to be a wrapper for rsync but keeping the familiar syntax.

2

u/elerenov Dec 25 '20

That's good to know, I had no idea!

3

u/happymellon Dec 25 '20

It could have been a fever dream through, because it is isn't then I should make it so!

1

u/istarian Dec 25 '20

I hope not. That would be a mess of complexity just to copy a file or two now and then.

1

u/happymellon Dec 25 '20

I assumed it was because of the volume of advice out there talking about scp, trying to make it easier for beginners.

1

u/istarian Dec 25 '20

I think using ssh rules out making it easier...

2

u/Jethro_Tell Dec 25 '20

Why? Rsynk is going to use ssh unless you tell it otherwise. Sftp is going to use ssh. Nthe reason being that most linux boxed have that and most non laptop hosts are running a server.

15

u/speculi Dec 25 '20

Ugh... Just no.

scp will stay with us, they are just changing the default protocol for connection. End users should see no difference.

sshfs may be using a bit more resources, so what? For each task use correct instrument. SMB is perfect for file sharing with many clients on different OS's. NFS is just tricky to set up correctly and I know nobody who would use it, but hey, it's very efficient and you may pick it up if you have a share for 100k Unix clients. sshfs is unbeatable if you need to move many files over ssh quickly.

7

u/elerenov Dec 25 '20 edited Dec 25 '20

I do use NFS at home and for work. I use it for personal purposes because I am comfortable with it, and for work because I need high performance and I have only Linux systems.

What disappoints me is that if you want security (something more than plain "IP based authentication"), you have to setup a Kerberos realm and everything. A bit of a pain. For my use case I would have been fine with a shared secret to authenticate hosts.

1

u/insanemal Dec 25 '20

I just use CephFS. But that's because I want solid redundant storage.

It's got a neat permissions model.

6

u/elerenov Dec 25 '20

What do you mean by "dedicated remote filesystems"?

0

u/[deleted] Dec 25 '20

True SCP is being abandoned or discontinued or whatever with newer SSH versions, but at least SSHFS uses SFTP instead so should keep working going forward.

0

u/[deleted] Dec 26 '20

[deleted]

1

u/todbanner Dec 27 '20

I completely forgot about samba when I made this post. I just thought linux, ssh, there must be a way and there this was. What are the advantages in your use case for sshfs over samba?

0

u/[deleted] Dec 27 '20

[deleted]

1

u/todbanner Dec 27 '20

That's why I forgot. Samba / windows filesharing makes me think that's how you get windows to share. If you need to share with linux it's ssh... Dur :)