Generally, we can mount folders on remote servers through the samba protocol. However, not all servers have opened the samba port, especially in the case of the external network, usually only one ssh port is opened. And sshfs realizes mounting the hard disk on the remote server to the local through the simulation of the ssh protocol. That is to say, as long as your server supports ssh connection, you can mount the server's hard disk locally, and then use the local method to operate the files on the hard disk.
At present, there are two schemes for the implementation of sshfs. The first scheme, winfsp + sshfs-win, is still being maintained and updated, and it is recommended to use it; the second scheme, win-sshfs + dokan, has not been updated for many years (the last update of win-sshfs is 2016), and not as efficient as the first one.
Method 1: winfsp + sshfs-win (recommended)
download
Go directly to the release of the corresponding project on github to download the latest version. Note that sshfs-win has a minimum version dependency on winfsp (downloading the latest version is generally sufficient). In addition, there is a GUI (graphical user interface) available for download, it is recommended to download .
- sshfs-win:Releases · winfsp/sshfs-win · GitHub
- winfsp:Releases · winfsp/winfsp · GitHub
- SSHFS-Win Manager:Releases · evsar3/sshfs-win-manager · GitHub (GUI,可选)
quick use
You can use the GUI graphical interface (method A) or manually mount it (method B). It is recommended to use the GUI graphical interface.
Way A: Use GUI (recommended)
new connection
After installing the above three software, open the GUI interface as follows, click Add Connection
:
SSHFS-Win Manager GUI main interface
Fill in each item in turn:
- NAME: Give the remote server a name
- Connection: remote server configuration, such as IP, port, remote user name, authentication method (password, or key [reference: SSH key management and password-free login ])
- Remote: remote directory configuration, after mounting, it will become the root directory of the corresponding local drive letter
- Local: Local drive letter setting (be careful not to conflict with existing drive letters)
Examples are as follows:
add connection
Click Save
Save.
hang in remote directory
Click the button on the main interface 连接
to mount the remote directory locally:
The main interface after adding a new connection
At this time, the remote directory has appeared in the local resource manager. If it does not appear, you can refresh it, or directly click the button 连接
on the left of the button on the GUI main interface 打开文件夹
to enter the directory.
Local mount succeeded
For long-term use, it is recommended to open it in the settings of the main interface 开机自启
:
Turn on the boot
Method B: Manually mount
mount path
1. SSH uses the default port (22)
At this time, the corresponding ssh login command is ssh username@remote_ip
, then use sshfs-win to mount the remote server root directory and the address of the home directory:
BASH
1 2 3 4 5 6 |
# root directory \\sshfs.r\username@remote_ip\ # home directory \\sshfs\username@remote_ip\ # or \\sshfs.r\username@remote_ip\home\username\ |
For example: \\sshfs.r\[email protected]\
, note that the separator in the path is the backslash used by windows \
.
2. SSH uses other ports (extranet port forwarding to connect to intranet servers)
At this time, the ssh login command is ssh -p port username@remote_ip
, the corresponding sshfs-win mount remote server root directory and the address of the home directory can remote_ip
be added after the previous !port
:
BASH
1 2 3 4 5 6 |
# root directory \\sshfs.r\username@remote_ip!port\ # home directory \\sshfs\username@remote_ip!port\ # or: \\sshfs.r\username@remote_ip!port\home\username\ |
For example: \\sshfs.r\[email protected]!34567\
.
Login to mount remote directory
Enter the above sshfs
path into the address bar of Windows File Explorer, and enter the password to enter. ( Note: The account displayed in the pop-up window is the local account of Windows, which does not need to be modified. The user name of the remote server has been included in the previous sshfs
path, so here you only need to enter the corresponding password of the remote user normally.)
For commonly used remote directories, it is recommended to 映射网络驱动器
mount them locally for a long time.
map network drive
In 映射网络驱动器
, you can assign the drive disk number yourself, and then 文件夹
enter the above sshfs
path in , click Finish and enter the password in the pop-up login box to complete the mount.
Enter the sshfs path
Afterwards, all remote directories that have been mounted can be seen in the network locations of the windows file explorer:
Local mount succeeded
Detailed parameters (can be skipped, check again when needed)
The specific syntax of sshfs-win is as follows, []
the content in which is optional, if it is the default value, you can leave it blank:
BASH
1 2 3 |
\\sshfs\[LOCUSER=]REMUSER@HOST[!PORT][\PATH] \\sshfs.r\[LOCUSER=]REMUSER@HOST[!PORT][\PATH] \\sshfs.k\[LOCUSER=]REMUSER@HOST[!PORT][\PATH] |
-
REMUSER
: That is, remote user, which refers to the user name when logging in to the remote host through SSH. -
HOST
: remote server, such as IP address, DNS server name or DNS server IP address -
PORT
: The port number used for SSH login (optional, the default is SSH(22) port). -
PATH
: The remote server path to enter, which can be set as follows:- The prefix
sshfs
corresponds toHOST:~REMUSER/PATH
, that is,home
the relative path relative to the user directory on the remote server:/home/remote_user/PATH
. - The prefix
sshfs.r
corresponds toHOST:/PATH
the path relative to the root directory on the remote server:/PATH
. - The prefix
sshfs.k
is the same as the first item, corresponding toHOST:~REMUSER/PATH
, but it uses the SSH key under the current local user of Windows%USERPROFILE%/.ssh/id_rsa
for authentication (remote server configuration is required, you can refer to SSH key management and password-free login ), and no password is required. (Note: When using the first two connections, Windows will also remind you to remember the password, so you only need to enter the password for the first time and remember it)
- The prefix
-
LOCUSER
Windows local user name, can be left blank.
Method 2: win-sshfs + Dokan (old, not recommended)
download
win-sshfs depends on Dokan, so install Dokan first and then install win-sshfs normally:
use
Open win-sshfs, click Add, enter the address, port number, user name and password of the server to be linked on the interface, and set the directory to be mounted, click save, and ensure that you can connect through ssh, click mount, you can mount the directory locally, as shown in the following figure:
win-sshfs configuration
Checking my computer, I found that 设备和驱动器
there is an additional storage device (different from the network location displayed in method 1), as shown in the figure:
Local mount succeeded