Home

Awesome

telescope-ssh-config

Don't ever type ssh user@host:port again (at least less often).

Easily start an SSH session from Neovim using Oil or Netrw.

https://github.com/jsongerber/telescope-ssh-config/assets/18051702/3c50fa6a-747b-497a-9a7f-2a7199c0c535

[!NOTE]
Tested on a fairly unsophisticated ssh_config file, see ssh-config for more information.

See :h telescope-ssh-config if you are in Neovim.

🚀 Usage

This plugin provides a single command, :Telescope ssh-config, which will open a Telescope window with all the hosts in your ssh config file. You can then select a host to connect to.

🔧 Requirements and dependencies

📋 Installation

-- This is where you have set up Telescope
{
    'nvim-telescope/telescope.nvim',
    -- …other telescope settings
    dependencies = {
        -- …other dependencies
        'jsongerber/telescope-ssh-config',
    },
    config = function()
        require('telescope').setup {
            -- …other settings
            extensions = {
                -- This is default and can be ommited
                ['ssh-config'] = {
                    client = 'oil', -- or 'netrw'
                    ssh_config_path = '~/.ssh/config',
                },
            },
        }

        -- …other Telescope extensions
        telescope.load_extension 'ssh-config'

        -- Optional: map :Telescope ssh-config to a keymap
        vim.keymap.set({ 'n', 'v' }, '<leader>fc', '<cmd>Telescope ssh-config<CR>', { desc = 'Open an ssh connexion' })
    end,
}
use({
    'nvim-telescope/telescope.nvim',
    -- …other telescope settings
    requires = {
        -- …other dependencies
        'jsongerber/telescope-ssh-config',
    },
    config = function()
        require('telescope').setup {
            -- …other settings
            extensions = {
                -- This is default and can be ommited
                ['ssh-config'] = {
                    client = 'oil', -- or 'netrw'
                    ssh_config_path = '~/.ssh/config',
                },
            },
        }

        -- …other Telescope extensions
        telescope.load_extension 'ssh-config'

        -- Optional: map :Telescope ssh-config to a keymap
        vim.keymap.set({ 'n', 'v' }, '<leader>fc', '<cmd>Telescope ssh-config<CR>', { desc = 'Open an ssh connexion' })
    end,
})

⚙ Configuration

require('telescope').setup {
    extensions = {
        -- This is the default configuration and can be ommited
        ['ssh-config'] = {
            client = 'oil',
            ssh_config_path = '~/.ssh/config',
        },
    },
}
OptionTypeDescriptionDefault value
clientStringThe client to use to connect to the host. Can be oil or netrw.'oil'
ssh_config_pathStringThe path to the ssh config file you would like the hosts to be read from.'~/.ssh/config'

🧰 Commands

CommandDescription
:Telescope ssh-configOpen a Telescope window with all the hosts in your ssh config file. You can then select a host to connect to.

🚧 SSH Config

The plugins uses the ssh_config file to get the hosts, it reads the host argument and run ssh -G host to get the host information. My ssh_config file looks like this:

Host host1
    HostName host1.com
    User user1
    Port 22

If you have a more complex ssh_config file and the plugin doesn't work, please open an issue with an example of your ssh_config structure and explain (like I'm 5) how you are using it to connect to the host and how it differs from my config.

⌨ Contributing

PRs and issues are always welcome. Make sure to provide as much context as possible when opening one.

📝 TODO

Will do if there is demand (open issue or PR)

📜 License

MIT © jsongerber

Shameless plug

See my other plugins: