Browse Source

Ticket #1535: SFTP support

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Slava Zanko 13 years ago
parent
commit
da03697e84
10 changed files with 126 additions and 0 deletions
  1. 2 0
      configure.ac
  2. 5 0
      doc/INSTALL
  3. 38 0
      doc/man/mc.1.in
  4. 41 0
      doc/man/ru/mc.1.in
  5. 3 0
      lib/keybind.c
  6. 1 0
      lib/keybind.h
  7. 2 0
      m4.include/mc-vfs.m4
  8. 19 0
      m4.include/vfs/mc-vfs-sftp.m4
  9. 12 0
      src/filemanager/cmd.c
  10. 3 0
      src/filemanager/cmd.h

+ 2 - 0
configure.ac

@@ -573,6 +573,8 @@ src/vfs/fish/helpers/Makefile
 
 src/vfs/ftpfs/Makefile
 
+src/vfs/sftpfs/Makefile
+
 src/vfs/local/Makefile
 
 src/vfs/sfs/Makefile

+ 5 - 0
doc/INSTALL

@@ -20,6 +20,7 @@ Build requirements for GNU Midnight Commander
 - slang or ncurses
 - gettext
 - cvs
+- libssh2 >= 1.2.5 is required only for sftp vfs (1.2.7 if you need ssh-agent support)
 
 
 Installation instructions for GNU Midnight Commander
@@ -170,6 +171,10 @@ VFS options:
      (on by default)
      Support for FISH vfs
 
+`--enable-vfs-sftp'
+     (off by default)
+     Support for SFTP vfs
+
 `--enable-vfs-extfs'
      (on by default)
      Support for extfs

+ 38 - 0
doc/man/mc.1.in

@@ -3097,6 +3097,9 @@ system for Linux systems),
 .I fish
 (for manipulating files over shell connections such as rsh and ssh).
 If the code was compiled with
+.I sftpfs
+(for manipulating files over SFTP connections).
+If the code was compiled with
 .I smbfs
 support, you can manipulate files on remote systems with the SMB (CIFS)
 protocol.
@@ -3224,6 +3227,41 @@ Examples:
     sh://joe@noncompressed.ssh.edu/private
     sh://joe@somehost.ssh.edu:2222/private
 .fi
+.\"NODE "  SFTP (SSH File Transfer Protocol) filesystem"
+.SH "  SFTP (SSH File Transfer Protocol) filesystem"
+The SFTP file system is a network based file system that allows you to
+manipulate the files in a remote machine as if they were local.
+.PP
+To connect to a remote machine, you just need to chdir
+into a special directory which name is in the following
+format:
+.PP
+.I sftp://[user@]machine:[port]/[remote\-dir]
+.PP
+The
+.I user,
+.I port
+and
+.I remote\-dir
+elements are optional.  If you specify the
+.I user
+element, the Midnight Commander will try to login on the remote
+machine as that user, otherwise it will use your login name.
+.I port
+\- specify the port used by remote server (22 by default).
+If the
+.I remote\-dir
+element is present, your current directory on the remote machine will be
+set to this one.
+.PP
+Examples:
+.PP
+.nf
+    sftp://onlyrsh.mx/linux/local
+    sftp://joe:password@want.compression.edu/private
+    sftp://joe@noncompressed.ssh.edu/private
+    sftp://joe@somehost.ssh.edu:2222/private
+.fi
 .\"NODE "  Undelete File System"
 .SH "  Undelete File System"
 On Linux systems, if you asked configure to use the ext2fs undelete

+ 41 - 0
doc/man/ru/mc.1.in

@@ -3415,6 +3415,10 @@ MC может быть собран с поддержкой файловой с
 .\"FIle transfer over SHell filesystem"
 .br
 .\"LINK2"
+Файловая система SFTP (SSH File Transfer Protocol)
+.\"SFTP (SSH File Transfer Protocol) filesystem"
+.br
+.\"LINK2"
 Файловая система UFS (Undelete File System)
 .\"Undelete File System"
 .br
@@ -3575,6 +3579,43 @@ bash\-совместимая оболочка shell.
     sh://joe@noncompressed.ssh.edu/private
     sh://joe@somehost.ssh.edu:2222/private
 .fi
+.\"NODE "  SFTP (SSH File Transfer Protocol) filesystem"
+.SH "  Файловая система SFTP (SSH File Transfer Protocol)"
+Файловая система SFTP \- это сетевая файловая система, которая позволяет
+работать с файлами на удаленном компьютере так, как если бы они были
+расположены на вашем диске. Для того, чтобы это было возможно, на
+удаленном компьютере должен быть запущен sftp\-сервер.
+.PP
+Для соединения с удаленным компьютером нужно выполнить команду
+перехода в каталог (chdir), имя которого задается в следующем формате:
+.PP
+.I sftp://[user@]machine[:port]/[remote\-dir]
+.PP
+Элементы
+.IR user ", " port
+.I remote\-dir
+не обязательны. Если задан элемент
+.IR user ,
+то Midnight Commander будет регистрироваться на удаленный компьютер под
+этим именем, в противном случае \- под тем именем, с которым вы
+зарегистрированы в локальной системе.
+Если задан
+.I port
+то он будет использован для поключения к удалённому компьютеру.
+Если задан элемент
+.IR remote\-dir ,
+то указанный каталог станет текущим после соединения с удаленным
+компьютером.
+.PP
+Примеры:
+.PP
+.nf
+    sftp://onlyrsh.mx/linux/local
+    sftp://joe:password@want.compression.edu/private
+    sftp://joe@noncompressed.ssh.edu/private
+    sftp://joe@somehost.ssh.edu:2222/private
+.fi
 .\"NODE "  Undelete File System"
 .SH "  Файловая система UFS (Undelete File System)"
 В ОС Linux можно сконфигурировать файловую систему ext2fs, используемую

+ 3 - 0
lib/keybind.c

@@ -165,6 +165,9 @@ static name_keymap_t command_names[] = {
 #ifdef ENABLE_VFS_FTP
     {"ConnectFtp", CK_ConnectFtp},
 #endif
+#ifdef ENABLE_VFS_SFTP
+    {"ConnectSftp", CK_ConnectSftp},
+#endif
 #ifdef ENABLE_VFS_SMB
     {"ConnectSmb", CK_ConnectSmb},
 #endif

+ 1 - 0
lib/keybind.h

@@ -150,6 +150,7 @@ enum
     CK_Filter,
     CK_ConnectFish,
     CK_ConnectFtp,
+    CK_ConnectSftp,
     CK_ConnectSmb,
     CK_PanelInfo,
     CK_Jobs,

+ 2 - 0
m4.include/mc-vfs.m4

@@ -12,6 +12,7 @@ m4_include([m4.include/vfs/socket.m4])
 m4_include([m4.include/vfs/mc-vfs-extfs.m4])
 m4_include([m4.include/vfs/mc-vfs-sfs.m4])
 m4_include([m4.include/vfs/mc-vfs-ftp.m4])
+m4_include([m4.include/vfs/mc-vfs-sftp.m4])
 m4_include([m4.include/vfs/mc-vfs-fish.m4])
 m4_include([m4.include/vfs/mc-vfs-undelfs.m4])
 m4_include([m4.include/vfs/mc-vfs-tarfs.m4])
@@ -74,6 +75,7 @@ AC_DEFUN([AC_MC_VFS_CHECKS],
     AC_MC_VFS_EXTFS
     AC_MC_VFS_UNDELFS
     AC_MC_VFS_FTP
+    AC_MC_VFS_SFTP
     AC_MC_VFS_FISH
     AC_MC_VFS_SMB
 

+ 19 - 0
m4.include/vfs/mc-vfs-sftp.m4

@@ -0,0 +1,19 @@
+dnl Enable SFTP filesystem
+AC_DEFUN([AC_MC_VFS_SFTP],
+[
+    AC_ARG_ENABLE([vfs-sftp],
+                  AS_HELP_STRING([--enable-vfs-sftp], [Support for SFTP filesystem [[yes]]]))
+    if test "$enable_vfs" != "no" -a x"$enable_vfs_sftp" != x"no"; then
+        PKG_CHECK_MODULES(LIBSSH, [libssh2 >= 1.2.5], [found_libssh=yes], [:])
+        if test x"$found_libssh" = "xyes"; then
+            AC_MC_VFS_ADDNAME([sftp])
+            AC_DEFINE([ENABLE_VFS_SFTP], [1], [Support for SFTP filesystem])
+            MCLIBS="$MCLIBS $LIBSSH_LIBS"
+            enable_vfs_sftp="yes"
+        else
+            enable_vfs_sftp="no"
+            AC_ERROR([libssh2 >= 1.2.5 library not found])
+        fi
+    fi
+    AM_CONDITIONAL([ENABLE_VFS_SFTP], [test "$enable_vfs" = "yes" -a x"$enable_vfs_sftp" = x"yes"])
+])

+ 12 - 0
src/filemanager/cmd.c

@@ -1455,6 +1455,18 @@ ftplink_cmd (void)
 
 /* --------------------------------------------------------------------------------------------- */
 
+#ifdef ENABLE_VFS_SFTP
+void
+sftplink_cmd (void)
+{
+    nice_cd (_("SFTP to machine"), _(machine_str),
+             "[SFTP (SSH File Transfer Protocol) filesystem]",
+             ":sftplink_cmd: SFTP to machine ", "sftp://", 1, TRUE);
+}
+#endif /* ENABLE_VFS_SFTP */
+
+/* --------------------------------------------------------------------------------------------- */
+
 #ifdef ENABLE_VFS_FISH
 void
 fishlink_cmd (void)

+ 3 - 0
src/filemanager/cmd.h

@@ -38,6 +38,9 @@ typedef enum
 #ifdef ENABLE_VFS_FTP
 void ftplink_cmd (void);
 #endif
+#ifdef ENABLE_VFS_SFTP
+void sftplink_cmd (void);
+#endif
 #ifdef ENABLE_VFS_FISH
 void fishlink_cmd (void);
 #endif

Some files were not shown because too many files changed in this diff