Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sftp/scp support [gvfs,sshfs backends: separate projects; internal backend: see #247] #86

Closed
unxed opened this issue Sep 18, 2016 · 84 comments

Comments

@unxed
Copy link
Contributor

unxed commented Sep 18, 2016

native sftp/scp support (without using sshfs or something like it) would be nice
https://github.com/michaellukashov/Far-NetBox/

@unxed
Copy link
Contributor Author

unxed commented Sep 18, 2016

and thank you all guys for the work you are doing!

@invy
Copy link
Contributor

invy commented Sep 19, 2016

We've had a discussion in the #14 about netbox. It's questionable, whether it's needed in linux. I think the better solution is to use fuse, how it's done in linux file manager, because linux can mount almost everything and far only need to utilize this capabilities.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

What about implementing native far plugin as a helper for establishing ssh connection and mounting remote fs via fuse, while entering and storing ssh credentials inside Far as it is done on windows? Commonly used linux FMs also behave like this.

upd: ssh credentials may be stored inside system wallet if possible.

upd 2: linux can mount ftp via fuse also, but I see ftp plugin ported ;)

@invy
Copy link
Contributor

invy commented Sep 20, 2016

Yep, in my opinion it's how this should work. Kinda sophisticated mount point manager.

BTW use key based authentication for ssh

@unxed unxed changed the title port netbox plugin sftp/scp support Sep 20, 2016
@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

Kinda sophisticated mount point manager.

Agree, it would be great.

btw, mount point manager inside far itself - sounds like a miracle :)

BTW use key based authentication for ssh

not worth time for temporary experimental VMs :)

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

Kinda sophisticated mount point manager.

quoting discussion with one of far manager windows fans:

ведь вот ничего ж сложного совместить вывод всех видимых разделов всех видимых носителей на панельку с автоопределением файловой системы и монтрованием (с автосозданием точки монтирования с именем по метке или серийному номеру раздела) куда-нибудь в /media одним нажатием энтера

@invy
Copy link
Contributor

invy commented Sep 20, 2016

It's not difficult, but it needs to be implemented, so everybody who has time are welcome to try.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

Not sure if I have enough skills to do it. My last c/cpp expirience was years ago. May try to look into the code next week if I have some luck :)

@invy
Copy link
Contributor

invy commented Sep 20, 2016

It's not that I'm somehow suggesting, that you should do it. I was addressing everybody, who read this issues. I think, good contribution would be for example to investigate which c++ libraries could be utilized for this task and how it's done by nautilus,pcmanfm, dolphin and other file managers.

@elfmz
Copy link
Owner

elfmz commented Sep 20, 2016

There're some limitations of mount:

  1. it requires root access to mount something that is not of fstab
  2. FS caching prevents using it for 'real-time' file-exchange
    So netbox is still on the shelf. Lieff disabled most of the unprotable code frpom it and the biggest problem now that it uses Windows-specific async sockets API that needs to be stupidly re-written with select or poll. Or may be cover that API in WinPort..

@invy
Copy link
Contributor

invy commented Sep 20, 2016

Fuse does not require root priveleges. And it's not a problem to use gksu, or similar mechanism.

@invy
Copy link
Contributor

invy commented Sep 20, 2016

@volth exactly. This also good point why it makes no sense porting old far plugins and then supporting them.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

caja does that somehow without asking for root password.
mounts to something like
/run/user/1000/gvfs/sftp:host=SERVERNAME,user=SERVERUSER
mount says it is
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

it's almost comfortably usable with far then, but that I want is establishing connections from far itself :)

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

looks like caja uses this API for mounting:
https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/gio/GMountOperation.html

see https://github.com/mate-desktop/caja/blob/master/src/caja-connect-server-operation.c for details

upd: as caja also allows to connect to webdav and windows shares, using this api may solve that issues too.

upd2: possible limitation: not sure if that API supports key based auth.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

another issue is the possibility to execute commands remotely (that would be ideal).
afaik netbox does that by executing separate putty session.
not sure about best solution if implementing sftp panel via mount.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

That about implementing GMountOperation shim as a separate plugin as temporary scaffold while proper implementation is discussed? There are still many cases then you even can not choose key based auth but still need sftp access (accessing shared hosting via public wifi, for example). This may be a fastest way to implement windows shares access also.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

@invy
Copy link
Contributor

invy commented Sep 20, 2016

I wonder whether there is DE agnostic lib for this.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

Had a brief look into the Dolphin's code. It uses KDE's KIO:
https://api.kde.org/frameworks/kio/html/classKProtocolManager.html
(see
https://quickgit.kde.org/?p=dolphin.git&a=blob&h=116168a4b121d33d21c8f753bd18fda77e475c9a&hb=ca53974181c17234f4522bd1635d4c0ab4281e1d&f=src%2Fviews%2Fdolphinremoteencoding.cpp
for details).

btw, GMountOperation neither depends on GNOME nor MATE. AFAIK, the only required dependency is GLib.

There is a third-party tool for managing remote fs mounts, called Gigolo, and it also uses gvfs:
http://www.uvena.de/gigolo/index.html
Guess if there were better choise, authors would have used it instead for sure.

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

As of XFCE, the most popular answer on "how to do it" also references gvfs:
http://askubuntu.com/questions/70423/how-do-i-connect-to-a-server-with-thunar-in-xubuntu

The second answer suggests to use gigolo tool mentioned above (which uses gvfs also).

Looks like it is the most popular/portable choise.

@invy
Copy link
Contributor

invy commented Sep 20, 2016

Hm, well. Then next thing is to make some kind of proof of concept with gvfs. :)

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

upd: gvfs is ok for key-based auth. see this thread:
https://ubuntuforums.org/showthread.php?t=1443983

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

gvfs also provides command-line mount tool. Maybe it can be used for proof-of-concept implementation:
http://manpages.ubuntu.com/manpages/trusty/man1/gvfs-mount.1.html
usage example:
gvfs-mount sftp://user@server
It will ask for password if needed. If there is a problem sending a password to it via stdin, there are serveral possible solutions available:
http://stackoverflow.com/questions/7005876/gvfs-mount-specify-username-password

Remaining task is to store connection info and user credentials, but farftp already implements it (using system wallet may be left to be a future improvement).

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

btw, is it hard to port something like this:
https://github.com/trexinc/evil-programmers/tree/master/pygin

Pygin
Very basic adapter to write Far Manager plugins in Python 3.

?

if there were any scripting language adapter for far, I could try to implement this by myself :)

@invy
Copy link
Contributor

invy commented Sep 20, 2016

The difficult thing is to know FAR plugin API and how to use it, since I've never developed plugins for FAR :)
I suppose it's fairly easy to create panel, put link to the panel into drive menu and fill panel with some custom entries (for mount points). And make some dialog which would allow to create/edit this entries. And add action, which causes gvfs to mount the specified mount point.

This looks pretty straight forward (actually another plugin, which should be easy to implement in linux with modern c++):
https://github.com/svn2github/farmanager/blob/master/plugins/proclist/Proclist.cpp

    if (Opt.AddToDisksMenu)
    {
        static const wchar_t *DiskMenuStrings[1];
        DiskMenuStrings[0]=GetMsg(MPlistPanel);
        Info->DiskMenu.Guids=&MenuGuid;
        Info->DiskMenu.Strings=DiskMenuStrings;
        Info->DiskMenu.Count=ARRAYSIZE(DiskMenuStrings);
    }

Adds panel to disk menu.

And (I suppose) relevane callbacks for panel:

intptr_t WINAPI GetFilesW(struct GetFilesInfo *Info)
{
    return ((Plist *)Info->hPanel)->GetFiles(Info->PanelItem,(int)Info->ItemsNumber,Info->Move,&Info->DestPath,Info->OpMode);
}
intptr_t WINAPI ProcessPanelEventW(const struct ProcessPanelEventInfo *Info)
{
    return ((Plist *)Info->hPanel)->ProcessEvent(Info->Event,Info->Param);
}


intptr_t WINAPI ProcessPanelInputW(const struct ProcessPanelInputInfo *Info)
{
    return ((Plist *)Info->hPanel)->ProcessKey(&Info->Rec);
}

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

Not sure if remote fs should be placed inside drive menu. The way I see it is a farftp-like plugin which displays on a panel a list of saved connections, and a) if connected - changes panel's path to mount point b) if not connected - executes gvfs-mount and goto a)

This may be implemented via modifying farftp by removing all ftp protocol releated stuff and adding very little bit of new code.

2-3 extra keystrokes to reach target place are not a problem for proof-of-concept implementation :)

@invy
Copy link
Contributor

invy commented Sep 20, 2016

This may be implemented via modifying farftp by removing all ftp protocol releated stuff and adding very little bit of new code.

It's MUCH easier to implement this from scratch, then to dig through old poorly written code ;)

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

This concept is still easier to implement as there is no need to touch drive menu except for adding one entry for plugin itself :)

@unxed
Copy link
Contributor Author

unxed commented Sep 20, 2016

Implementing this as a simpliest plugin example can be good starting point for newbie linux plugin authors.

@invy
Copy link
Contributor

invy commented Oct 5, 2016

Nothing is so eternal as temporary things :)

Better solution: far provides function to add plugin controlled entries to disk menu. I.e. map: plugin id -> vector of entries. When on such entry is selected, plugin gets notification. When plugin is removed, all entries associated with plugin are removed.

@elfmz
Copy link
Owner

elfmz commented Oct 5, 2016

Text file in profile is easily configurable manually, that's why sooner or later I will commit such a feature. Another question if it fair or not to use such user-editable thing from plugin as API.
About notification: as I understand it then should produce dynamically changed submenu? IMHO not better than just usually going to plugin's panel. Better (and logical) would be possibility to modify that menu not only from startup but at any moment.

@invy
Copy link
Contributor

invy commented Oct 5, 2016

File has problems, because it's not synchronised with plugin. If plugin isn't loaded, you read disk menu entries from file try to open it, it will fail. Plugin won't be able also to handle mount for this entries.

About interface: no. I didn't mean sub menu. I've meant more simply grouping.

File is good for favourites, but once again, if we have API interface for modifying the disk menu, it could be managed by plugin.

@elfmz
Copy link
Owner

elfmz commented Oct 5, 2016

Currently there is same problem: you may type ftp://foo in far's command line while ftp plugin not active - it will not work, and nobody cares about that :)
Also far may be smart enough to check pathes, see that its path to plugin and dont show it if not active.

@invy
Copy link
Contributor

invy commented Oct 5, 2016

Plugin registers "ftp" prefix during initialization (there is corresponding structure member for it). Plugin can also have access to cmd line input and do actions. If plugin is not registered of course "ftp" is not registred and far can't do anything about commands starting with "ftp" and it's perfectly fine.

If fa would put entries in disk menu on it's own without having the plugin, it's a problem. So I think only plugin should be responsible for its entries and when it's not loaded, there won't be any entries and no problems. Anyway central file introduces redundance and redundance causes inconsistence and so should be avoided if there is no explicit need in it.

@invy
Copy link
Contributor

invy commented Oct 5, 2016

Plugin also really needs callback, when entry it has responsible for, is selected in disk menu, because it needs to mount eventually (I.e after restart)

@invy
Copy link
Contributor

invy commented Oct 6, 2016

JFYI: Implementation will take a little longer because of unforeseen problems with GMainLoop and signals. Somehow gmainloop creates another thread and receives signals there. I've found the way to call main thread (for opening authentication dialog), but this solution (with the GDispatcher and GMainContext) i don't really like. I'll look into this issue next week, so don't worry, I'm not forgetting about this plugin :)

(Disclaimer: I've never developed for glib, gio and gtk+ so I'll need to read documentation about this things when I have time)

@unxed
Copy link
Contributor Author

unxed commented Nov 17, 2016

Implementation will take a little longer

any news on this?

@invy
Copy link
Contributor

invy commented Nov 17, 2016

Yes. The news are: I was lazy :)

I need to conquer my laziness and write user interaction (maybe on weekend), to allow login, password and domain name input.

@unxed
Copy link
Contributor Author

unxed commented Nov 18, 2016

Can I do something to give you some pleasent mood & motivation to do it?
Maybe a postcard or something like it? :)

@invy
Copy link
Contributor

invy commented Nov 20, 2016

For some reason far is locking up, when I try to open InputBox. I'm running out of ideas. At the beginning I was thinking, it's due to calls from another threads (where gio callback got called). I've changed the plugin, so that all calls to Far API would happen on the single thread... this didn't help. Far is stuck in message processing loop not accepting any input.

I hope I can find something...

@unxed
Copy link
Contributor Author

unxed commented Apr 26, 2017

https://github.com/cycleg/far-gvfs

may be closed now?

@unxed
Copy link
Contributor Author

unxed commented May 9, 2017

  1. Problem is actually solved with far-gvfs
  2. There is (feature request) NetBox Plugin [SFTP/FTP/FTP(S)/SCP/WebDAV client] #247.

Closing.

@unxed unxed closed this as completed May 9, 2017
@asimonov
Copy link

asimonov commented Sep 11, 2018

@unxed , on MacOS+far2l I am currently using sshfs to mount Ubuntu 16.04 system under normal user who can 'sudo' in ssh.

I can browse Ubuntu files in the mount and edit user files. But if I edit files requiring sudo i get window asking 'operation requires privileges elevation', 'enter sudo password:'. I do this and then nothing happens. The question keeps popping up.

What is the good way to handle occasional edit that requires sudo?

@unxed
Copy link
Contributor Author

unxed commented Sep 15, 2018

@asimonov guess you should open the separate issue for this.

@singalen
Copy link
Contributor

Can I voice my concern for this issue? As mentioned here, on Mac gvfs solution is dissatisfactory because:

  • fuse doesn't come with the OS;
  • it requires installing a kernel module, which very few Mac users will do;
  • connecting to multiple new hosts with sshfs each day is inconvenient.
  • asimonov's issue is a consequence of the imperfect integration too.

I believe, this issue is still the appropriate place for discussion?

@asimonov
Copy link

asimonov commented Oct 29, 2018 via email

@singalen
Copy link
Contributor

singalen commented Oct 29, 2018

Having thought of it, we could do the same thing as NetBox did with WinScp: frankenstein some existing scp/sftp parts from OpenSSH/Pytty/FileZilla into the old Far's FTP client.

@singalen singalen mentioned this issue Nov 2, 2018
@unxed
Copy link
Contributor Author

unxed commented Nov 5, 2018

connecting to multiple new hosts with sshfs each day is inconvenient.

Fix released :)
https://github.com/unxed/far2l-fuse

if I edit files requiring sudo i get window asking 'operation requires privileges elevation', 'enter sudo password:'. I do this and then nothing happens

@asimonov's issue is a consequence of the imperfect integration too.

NetBox was unable to do the trick also. Btw, it looks like it's still possible to partially solve this using sshfs -o sftp_server="sudo /usr/lib/openssh/sftp-server" (I'm planning to add support for custom mount options to far2l-fuse later) or using dedicated keypairs: https://unix.stackexchange.com/questions/111026/how-to-use-sftp-on-a-system-that-requires-sudo-for-root-access-ssh-key-based-a/111040#111040

fuse doesn't come with the OS
it requires installing a kernel module, which very few Mac users will do

Got no mac, just wondering. Is it actually so hard to get sshfs/fuse running there? o_O
10 seconds of googling "sshfs macosx" gives tons of manuals that look relatively easy to follow.

Anyway, supplying a script for easy sshfs/fuse installation depending on running OS is much less work than developing sftp implementation from scratch and keeping it up to date with actual SSH protocol, ciphers, hashes, etc.


Btw, let's continue discussing SFTP-releated stuff here: #247
Why do we use closed-as-duplicate issue instead of open one?
English is welcome in every issue here AFAIK.

@singalen
Copy link
Contributor

singalen commented Nov 5, 2018

Wow, thank you very much!

Got no mac, just wondering. Is it actually so hard to get sshfs/fuse running there? o_O

Hm, that sounds somewhat condescending.

It's not TOO HARD, it's quite INCONVENIENT and UNCONVENTIONAL. Unlike Linux, it's not normal to install new kernel modules on Mac. Installation itself doesn't run so smoothly as on Linux. On Mac, fuse and sshfs are two different software packages, and last time I tried they required some dances to get them to work together.

Most of the tutorials get outdated with a new OS release, as the names of the kernel modules change.

On a more attentive look, they are not too easy, as they address 2 different ways to install FUSE on Mac. It's a sign that none of these is perfect, both have their quirks.

Another quirk is that the first Google hit, https://github.com/osxfuse/osxfuse/wiki/SSHFS, refers to SSHFS package dated in 2014. It's 3 OS releases old. I can bet it won't work and will require searching for/building another package. I can bet it takes some effort to find a compatible pair of FUSE and SSHFS packages.

I honestly tried to run sshfs once, and ran into several unexpected issues. I'm not ready to try it again right now, but I eventually will. I will do my best to gather a list of problems that occured :)

This all totals to "too much effort to get just another file manager running", while it, frankly speaking, could just work out of box.

@unxed unxed changed the title sftp/scp support sftp/scp support [gvfs,sshfs backends: parially done; internal backend: see #247] Nov 6, 2018
@unxed unxed changed the title sftp/scp support [gvfs,sshfs backends: parially done; internal backend: see #247] sftp/scp support [gvfs,sshfs backends: partially done; internal backend: see #247] Nov 6, 2018
@unxed unxed changed the title sftp/scp support [gvfs,sshfs backends: partially done; internal backend: see #247] sftp/scp support [gvfs,sshfs backends: separate projects; internal backend: see #247] Nov 6, 2018
@unxed
Copy link
Contributor Author

unxed commented Nov 6, 2018

Summary:

@asimonov
Copy link

asimonov commented Nov 9, 2018

@unxed thanks a lot! trying gvfs and fuse plugins now

Just checked my records and I use FUSE + SSHFS. Then browse/edit files on mounted file systems in far2l.

This is what my records show:
installed sshfs 2.5.0 from https://github.com/osxfuse/sshfs/releases
installed osx fuse 3.7.1 https://osxfuse.github.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@singalen @asimonov @invy @unxed @elfmz and others