matteosecli / Ulysses-doc

The missing documentation for the cluster Ulysses @ SISSA
https://ulysses.readthedocs.io
Creative Commons Attribution Share Alike 4.0 International
8 stars 2 forks source link

SFTP v SSHFS intrigue [Ubuntu 20.04 LTS] #1

Open beddalumia opened 3 years ago

beddalumia commented 3 years ago

HI! First of all thanks again for this beautiful doc. It's helping A LOT.

I have noticed a slight discrepancy between what you state about the advantges of SSHFS over SFTP and what actually happens in my setup (Ubuntu 20.04 LTS). Either something has changed in the while, or I'm failing to follow; or even something subtle may be happening behind the scenes. More on this later. o^O--,

1. About SFTP drawbacks:

« Mounting a folder via the SFTP protocol doesn’t make it behave exactly as a local folder. For example, you cannot open a local terminal in it. [...] »

The emphasized part appears to be a false/outdated statement: if I sftp connect to either Ulysses or the .phys workstation using the built-in procedure in Nautilus I can open a local terminal. I tested its true locality by opening $HOME/.bashrc with gedit on Ulysses; in a remote terminal this would have been impossibile for sure. o^O--,

2. About SSHFS advantages:

Actually you don't really state it, but since you are referring to it as

« a more flexible solution that allows you to open local terminals »

I assumed it to be able to also open remote terminals (which is indeed useful!). But if I follow are the steps you describe to link a local folder to the cluster storage I don't see the option to open the remote terminal. So in the end it appears as the more flexible solutions is actually SFTP.

3. About SSHFS being broken:

I could not manage to effectively bookmark the SSHFS link. If I click on Add bookmark I get the local folder bookmaked, but not the SSHFS link! If I manage to unmount (which is definitely flawed, as you state...) I lost the link forever: clicking the bookmark does just open the local folder, withour any stargate opening. If I instead access to SFTP via + Other locations and I bookmark it, everything works fine and pleasant. So I think you'd definitely want to recommend SFTP over SSHFS in the end...


o^O--, Finally a disclaimer: at first I just trusted you and never tried to open a local terminal with SFTP (but I'm sure the option was there...). Then I think I may have tried and failed to open .bashrc with gedit. But in all the noise of what I was doing (and suffering) I'm not really sure about it. Just know that I've done everything with vim in the end. After all the true work&pain with my installations I returned to the guide to supposedly upgrade to SSHFS and encountered all the issues described in points 2. and 3.. So just after having SSHFS installed I retried with native nautilus SFTP and succeded with the local terminal and gedit. May it be that just installing SSHFS somehow improves the nautilus SFTP experience?

I may uninstall SSHFS to shed light more systematically on the issue, but most probably not in the immediate. Sorry for that, I need to go full-productive from tomorrow already. When I'll do it I'll come here to comment. Nevertheless to me it appears that for sure at least some rewriting of the Explore Files in a User-Friendly Way section is needed.

matteosecli commented 3 years ago

Hi @Bellomia, thanks for the report! 🙂

I've tested both SFTP and SSHFS on my own Ubuntu 20.04 machine (as well as on MacOS and Windows) and I have a very similar setup on my SISSA WS as well (RHEL 7). From my perspective (but it might be skewed), SSHFS has the non-trivial advantage of letting you deal with remote files as if they were on your local machine. This comes in really handy when you have to perform some locally run graphical post-processing that involves remote files, e.g. you have to do some analysis with MATLAB or some other similar stuff. With SFTP, you have to instruct MATLAB on how to retrieve and send files via the SFTP protocol; you have to use some external Java libraries that make the whole process overly complicated (albeit doable, I personally did it several times) and prone to memory leaks after prolonged usage; the situation is similar with other analysis tools. If you instead have your remote volume mounted in your local directory tree via SSHFS, you just open the remote file on your local MALTAB instance as if it were just some regular file, no extra SFTP fancy stuff needed; then SSHFS does all the job for you in the background by properly calling SFTP.

From the command line perspective, using SSHFS over plain SFTP is (I think) definitely easier; just try to exchange some files between your local machine and Ulysses via SFTP through the command-line sftp command, and then try to do the same after you've mounted a corresponding volume via sshfs. In the latter case, after you've mounted the volume, you can just use the regular mv command and forget about the fact that Ulysses is actually mounted as a remote folder.

Then, from the graphical interface perspective, Nautilus makes using SFTP definitely less painful; it shows you the remote location as if it was just a regular folder, you can graphically copy/paste and it has some useful perks like the "Open in remote terminal" thing which — I agree — is super useful. But with Nautilus SFTP, all this convenience is limited to Nautilus itself; if you try to open some remote file via your local terminal or via any other application (like MATLAB), then you're out of luck. That's why I think SSHFS is more convenient, as it does not limit these goodies to a single application like Nautilus, but it makes things easier system-wide. Yes, you unfortunately loose the "Open in remote terminal" option; I personally just have a shell alias that directly connects me to the cluster without having to type the full command every time, so I don't honestly miss the feature that much.

However I think you might be right about the bookmarking problems with SSHFS in Nautilus; I have to check whether ejecting the volume makes the bookmark disappear or not. And I should definitely clarify the fact that in order to mount the remote location via SSHFS you unfortunately have to use that command-line command each time, albeit you can always wrap it into a convenient script or just add an entry to /etc/fstab to have it automagically mounted at boot (although I'm not sure how it would work out with a VPN; for SISSA WS, instead, you should not have any issues since they are on the same network). Then, only after mounting, you can use the Nautilus bookmark that you've set up the first time. I should definitely clarify this point. 🙂

Then, it could also well be that Nautilus is trying to be smart and, if you have SSHFS installed, it switches to SSHFS when you try to mount a SFTP location. If instead SSHFS is not installed, it just uses regular SFTP. I honestly don't know whether this is the case or not, I have to investigate a little bit; but if this is really the case, then you've found a much easier way to deal with SSHFS that does not involve any command-line mount/unmount command and that would make the bookmarks finally work properly! 😄 It would really be a great thing to have; I'll try to investigate and update the guide if it turns out to be the case.

I'll also wait for your findings; anyway, always feel free to open a PR with corrections if you feel to. 😉

beddalumia commented 3 years ago

Ok, then my suspects of Nautilus launching SSHFS under the rug become stronger. Indeed a remote-terminal-only option isn't very much appealing and I'd personally find it barely useful (loads of matlab scripting in my life, and I'm kind of allergic to vim). So if "pure" SFTP does just that then yeah, an upgrade is very welcome.

I'll inform you asap about my findings on wheter Nautilus makes advantage od SSHFS or not. I mean, if yes (as it appears), that could be (at least for me) the ultimate solution. As for now I somehow have both the remote and local terminal option, can open files with gedit, can open and run a .m script with my local matlab installation: both with a local terminal -batch comand and opening the local GUI (though this is quite clumsy, as you now nowdays the frontend is slow and matlab gui adds to this laziness...); just tried!

Since my installation is currently in a sort of nirvana-state, I don't want to risk messing it up in any way right now. I'll convince someone (already in mind who ahah) to do the same steps, but carefully inspect this time what happens with nautilus sftp before attempting anything with SSHFS. So we'll know what nautilus can do if SSHFS is available :)

As for what it concerns your shell alias solution I've actually looked into it and implemented, and it's beautifull (plus now I enter the $HOME folder in Ulysses just typing "Ithaca", which is kind of cool 😆). But I think that if SSHFS integrates with Nautilus as well as it seems these aliases are actually superseded and in the end not needed anymore :D Also, I would totally avoid any kind of automated mounting at boot, whenever a vpn is involved. According to my unfortunate past experiences is just a mess that we don't really want... I mean, running a .sh script to mount SSHFS is not that much of a pain, and an alias for that would just perfectly fit I think.

Regarding PRs...I prefer to be supersure about something before submitting any proposed change! But sure, I'd like to contribute edits in future, when sure about them being safe :)

I'll update you!