A minimal, fast SSHFS integration for NeoVim that works with YOUR setup. No forced dependencies. Use your preferred file picker, search tools, and workflow to edit remote files without leaving your editor.
*� Smart Integration: Automatically detects and launches telescope, oil, neo-tree, nvim-tree, snacks, fzf-lua, mini, yazi, lf, nnn, ranger, or netrw. Your workflow, your choice.
Mount any host from your ~/.ssh/config
and browse remote files as if they were local. Jump between your local machine and remote mounts with a keystroke.
https://github.com/user-attachments/assets/20419da8-37b9-4325-a942-90a85754ce11
Software | Minimum | Notes |
---|---|---|
Neovim | >=0.10 |
Requires vim.uv support |
sshfs | any | sudo dnf/apt/pacman install sshfs or brew install sshfs |
SSH client | any | Usually pre-installed on most systems |
SSH config | working hosts | Hosts come from ~/.ssh/config |
{
"uhs-robert/sshfs.nvim",
opts = {
-- Refer to the configuration section below
-- or leave empty for defaults
},
}
use {
"uhs-robert/sshfs.nvim",
config = function()
require("sshfs").setup({
-- Your configuration here
})
end
}
Plug 'uhs-robert/sshfs.nvim'
Then in your init.lua
:
require("sshfs").setup({
-- Your configuration here
})
git clone https://github.com/uhs-robert/sshfs.nvim ~/.local/share/nvim/site/pack/plugins/start/sshfs.nvim
init.lua
:require("sshfs").setup({
-- Your configuration here
})
You can optionally customize behavior by passing a config table to setup().
[!NOTE] Only include what you want to edit.
Here's the full set of defaults for you to configure:
require("sshfs").setup({
connections = {
ssh_configs = require("sshfs.core.config").get_default_ssh_configs(),
sshfs_args = { -- these are the sshfs options that will be used
"-o reconnect", -- Automatically reconnect if the connection drops
"-o ConnectTimeout=5", -- Time (in seconds) to wait before failing a connection attempt
"-o compression=yes", -- Enable compression to reduce bandwidth usage
"-o ServerAliveInterval=15", -- Send a keepalive packet every 15 seconds to prevent timeouts
"-o ServerAliveCountMax=3", -- Number of missed keepalive packets before disconnecting
},
},
mounts = {
base_dir = vim.fn.expand("$HOME") .. "/mnt", -- where remote mounts are created
unmount_on_exit = true, -- auto-disconnect all mounts on :q or exit
},
handlers = {
on_disconnect = {
clean_mount_folders = true, -- optionally clean up mount folders after disconnect
},
},
ui = {
file_picker = {
auto_open_on_mount = true, -- auto-open picker after connecting
preferred_picker = "auto", -- one of: "auto", "telescope", "oil", "neo-tree", "nvim-tree", "snacks", "fzf-lua", "mini", "yazi", "lf", "nnn", "ranger", "netrw"
fallback_to_netrw = true, -- fallback to netrw if no picker is available
},
},
lead_prefix = "<leader>m", -- change keymap prefix (default: <leader>m)
keymaps = {
mount = "<leader>mm",
unmount = "<leader>mu",
edit = "<leader>me",
reload = "<leader>mr",
open = "<leader>mo",
grep = "<leader>mg",
},
log = {
enabled = false,
truncate = false,
types = {
all = false,
util = false,
handler = false,
sshfs = false,
},
},
})
[!TIP] The
sshfs_args
table can accept any configuration option that applies to thesshfs
command. You can learn more about sshfs mount options here.In addition, sshfs also supports a variety of options from sftp and ssh_config.
:SSHConnect [host]
- Connect to SSH host (picker or direct):SSHDisconnect
- Disconnect from current host (picker shown if multiple mounts):SSHEdit
- Edit SSH config files:SSHReload
- Reload SSH configuration:SSHBrowse
- Browse remote files using auto-detected file picker:SSHGrep [pattern]
- Search remote files using auto-detected search toolThis plugin optionally provides default keybindings under <leader>m
. These can be fully customized.
Mapping | Description |
---|---|
<leader>mm |
Mount an SSH host |
<leader>mu |
Unmount an active session |
<leader>me |
Edit SSH config files |
<leader>mr |
Reload SSH configuration |
<leader>mo |
Browse remote mount |
<leader>mg |
Grep remote files |
If which-key.nvim is installed, the <leader>m
group will be labeled with a custom icon (
).
You can override the keymaps or the prefix like this:
require("sshfs").setup({
lead_prefix = "<leader>m", -- change keymap prefix (default: <leader>m)
keymaps = {
mount = "<leader>mm",
unmount = "<leader>mu",
edit = "<leader>me",
reload = "<leader>mr",
open = "<leader>mo",
grep = "<leader>mg",
},
})
After connecting to a host with :SSHConnect
, the plugin mounts the remote filesystem locally. You can then:
Browse files: Use :SSHBrowse
to automatically launch your preferred file picker:
preferred_picker = "yazi"
to force a specific pickerSearch files: Use :SSHGrep [pattern]
to automatically launch your preferred search tool:
*� The Magic: The plugin intelligently detects what you have installed and launches it automatically, respecting your existing Neovim setup and preferences. No configuration required, it just works with whatever you're already using.
ssh_config
rather than manually adding hosts to make this as easy as possible.