Ticket #1535 (closed enhancement: fixed)

Opened 5 years ago

Last modified 21 months ago

Feature: support SCP/SFTP

Reported by: bilbo Owned by: slavazanko
Priority: major Milestone: 4.8.4
Component: mc-vfs Version: master
Keywords: Cc: replika
Blocked By: Blocking:
Branch state: merged Votes for changeset: committed-master

Description

Currently mc supports FISH (copying files over SSH), however, it seems that it does not work on some servers, namely if you don't have shell accound on the machine and only scp/sftp is allowed (for example sourceforge servers used for uploading released files)

FISH does not work, as does not work using ssh to connect (you are kicked out after connecting with message that shell access is denied), but commandline scp and sftp works here.

If would be nice to add support for scp and/or sftp to help transfer files to/from servers where shell is not available.

Attachments

0001-configure-don-t-fail-if-sftp-support-was-not-request.patch (2.0 KB) - added by slyfox 2 years ago.
fail only if user explicitely requested sftp

Change History

comment:1 Changed 5 years ago by bilbo

  • Version changed from 4.7.0-pre1 to master

comment:2 Changed 5 years ago by iNode

  • Milestone changed from 4.7 to VFS Standardisation

Thanks for the request.

FISH isn't scp/sftp it runs shell to navigate over remote system, so I think it will be another VFS plugin. But before it will be done, we should rework current VFS mechanisms to avoid some limitations.

comment:3 Changed 3 years ago by angel_il

branch: 1535_sftp
changeset: 1535_sftp

please review

comment:4 Changed 3 years ago by bilbo

  • Branch state set to no branch

In current state it fails compilation:

filemanager/.libs/libmcfilemanager.a(libmcfilemanager_la-panel.o): In function `_do_panel_cd':
/home/src/mc/src/filemanager/panel.c:2679: undefined reference to `mc_log'
/home/src/mc/src/filemanager/panel.c:2699: undefined reference to `mc_log'
/home/src/mc/src/filemanager/panel.c:2712: undefined reference to `mc_log'
/home/src/mc/src/filemanager/panel.c:2714: undefined reference to `mc_log'
/home/src/mc/src/filemanager/panel.c:2720: undefined reference to `mc_log'
filemanager/.libs/libmcfilemanager.a(libmcfilemanager_la-panel.o):/home/src/mc/src/filemanager/panel.c:2725: more undefined references to `mc_log' follow
collect2: ld returned 1 exit status

Commenting out all mc_log's fixes the problem.

However, there are more bugs:

If I connect, I see dialog with keys, etc ....

When I leave keys blank, sftpfs requests a password from me (even though ssh and fish does not require nay password due to ssh-agent having keys in memory)

Pressing "Esc" in the password dialog triggers a segmentation fault.

When I tried again and filled out right path to proper ssh key for the given host, it does not work (it asks me for password again aind since that host accepts only ssh keys and no passwords, I can't connect)

Also, when I use Left -> New SFTP link, then I enter machine name (for example "localhost") in first dialog, but then I press cancel at second dialog, I get "Cannot chdir to "/sftp://localhost" error message.

There also should be some way to set/pre-set all this extra settings for all the machines somewhere and not to ask for it again on each new connection.

comment:5 Changed 3 years ago by bilbo

Also, when making connecton to a host which is down (or if you make a typo and connect to a host which does not exist or does not have sshd), the message like "sftpfs: making connection to 192.168.1.203" appears and there is no possibility of cancelling the connection, resulting in mc being freezed.

comment:6 Changed 3 years ago by bilbo

  • Branch state changed from no branch to on rework

comment:7 Changed 2 years ago by slavazanko

  • Status changed from new to accepted
  • Owner set to slavazanko
  • Branch state changed from on rework to on review
  • Milestone changed from 4.8 to 4.8.4

Created branch 1535_vfs_sftp

Review, please.

Last edited 2 years ago by slavazanko (previous) (diff)

comment:8 Changed 2 years ago by replika

I checked out the branch 1535_vfs_sftp but got this error:

make[3]: Entering directory `/mnt/src/mc/src/filemanager'
  CC     libmcfilemanager_la-achown.lo
  CC     libmcfilemanager_la-boxes.lo
  CC     libmcfilemanager_la-chmod.lo
  CC     libmcfilemanager_la-chown.lo
  CC     libmcfilemanager_la-cmd.lo
cmd.c: In function 'sftplink_cmd':
cmd.c:1520:14: error: too few arguments to function 'nice_cd'
cmd.c:524:1: note: declared here
make[3]: *** [libmcfilemanager_la-cmd.lo] Error 1
make[3]: Leaving directory `/mnt/src/mc/src/filemanager'
./configure --enable-vfs-smb --enable-vfs-sftp --with-screen=ncurses

Which branch should I used to test this feature?

comment:9 Changed 2 years ago by slavazanko

This was happens as result of rebasing. Fixed.

Last edited 2 years ago by slavazanko (previous) (diff)

comment:10 Changed 2 years ago by slavazanko

  • Cc replika added

comment:11 Changed 2 years ago by replika

Thanks for your working on this feature. It works great so far.

BTW, how to disconnect a connection?
Tried cd but it is still connected; cd - will go back to sftp directory.

In "Active VFS list", it is displayed as //sftp://, but cannot change directory nor free the VFS.

Currently, I have to exit mc to close the connection.

comment:12 Changed 2 years ago by angel_il

  • Votes for changeset set to angel_il

comment:13 Changed 2 years ago by andrew_b

  • Votes for changeset changed from angel_il to angel_il andrew_b
  • Branch state changed from on review to approved

comment:14 Changed 2 years ago by slavazanko

  • Status changed from accepted to testing
  • Votes for changeset changed from angel_il andrew_b to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

Merged to master:

git log --pretty=oneline 7893cbf..da03697

comment:15 Changed 2 years ago by slavazanko

  • Status changed from testing to closed

comment:16 Changed 2 years ago by slyfox

  • Status changed from closed to reopened
  • Resolution fixed deleted

Stock ./configure fails if user does not have libssh2 headers.
The default behaviour is not to enable plugin unless user explicitly
requests is with --enable-vfs-sftp.

Attaching the patch to retain user friendly behaviour.

Changed 2 years ago by slyfox

fail only if user explicitely requested sftp

comment:17 Changed 2 years ago by IceMan

Midnight Commander from current git origin/master doesn't mention SFTP support in mc -V output.

$ LC_ALL=C mc -V

GNU Midnight Commander 4.8.3-95-g8ca27aa
Built with GLib 2.24.2
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, fish
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

comment:18 Changed 2 years ago by andrew_b

  • Votes for changeset committed-master deleted
  • Branch state changed from merged to no branch

comment:19 Changed 2 years ago by slavazanko

  • Status changed from reopened to accepted
  • Votes for changeset set to slavazanko
  • Branch state changed from no branch to on review

Created branch 1535_vfs_sftp_fixes
Review, please.

comment:20 Changed 2 years ago by andrew_b

  • Votes for changeset changed from slavazanko to slavazanko andrew_b
  • Branch state changed from on review to approved

comment:21 Changed 2 years ago by slavazanko

  • Votes for changeset changed from slavazanko andrew_b to committed-master
  • Branch state changed from approved to merged

Merged to master:

git log --pretty=oneline a343070..3786051

comment:22 Changed 2 years ago by slavazanko

  • Status changed from accepted to testing
  • Resolution set to fixed

comment:23 Changed 2 years ago by IceMan

When opening SFTP link to the remote server by using host alias from ~/.ssh/config MC start more than one sftp-server instance on the target server. If you use username@1.2.3.4 instead of host alias - MC works fine.

GNU Midnight Commander 4.8.3-121-g54b2b2f
Built with GLib 2.24.2
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish
Data types: char: 8; int: 32; long: 32; void *: 32; size_t: 32; off_t: 64;

Expected behaviour:
When open SFTP link by host alias MC must start only single sftp-server instance per SFTP link on the target server.

How to reproduce:
1) Create host record in ~/.ssh/config like following:

Host example
HostName 1.2.3.4
User username

2) Open SFTP link by using example as "Machine name"
3) Login to target server and count sftp-server instances

pgrep -u username sftp-server | wc -l

comment:24 Changed 2 years ago by andrew_b

  • Status changed from testing to reopened
  • Votes for changeset committed-master deleted
  • Version changed from master to 4.8.4
  • Branch state changed from merged to no branch
  • Milestone changed from 4.8.4 to 4.8.5
  • Resolution fixed deleted

comment:25 Changed 22 months ago by andrew_b

  • Milestone changed from 4.8.5 to Future Releases

comment:26 Changed 21 months ago by andrew_b

  • Status changed from reopened to closed
  • Votes for changeset set to committed-master
  • Version changed from 4.8.4 to master
  • Branch state changed from no branch to merged
  • Milestone changed from Future Releases to 4.8.4
  • Resolution set to fixed

Broken aliases will be fixed in #2923.

Note: See TracTickets for help on using tickets.