{"id":13898308,"url":"https://github.com/pbogut/vim-dadbod-ssh","last_synced_at":"2025-10-30T06:23:37.521Z","repository":{"id":53342444,"uuid":"335437804","full_name":"pbogut/vim-dadbod-ssh","owner":"pbogut","description":"NeoVim plugin that allows vim-dadbod connections to remote servers through ssh.","archived":false,"fork":false,"pushed_at":"2024-05-19T08:37:24.000Z","size":16,"stargazers_count":16,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-07T18:45:57.925Z","etag":null,"topics":["dadbod","database","neovim","neovim-plugin","vim"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pbogut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-02T22:14:56.000Z","updated_at":"2024-06-20T10:27:23.000Z","dependencies_parsed_at":"2022-08-13T02:31:22.301Z","dependency_job_id":"909e4d87-2da0-46be-906d-9dfa8b1c89db","html_url":"https://github.com/pbogut/vim-dadbod-ssh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbogut%2Fvim-dadbod-ssh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbogut%2Fvim-dadbod-ssh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbogut%2Fvim-dadbod-ssh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbogut%2Fvim-dadbod-ssh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pbogut","download_url":"https://codeload.github.com/pbogut/vim-dadbod-ssh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226274780,"owners_count":17598860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dadbod","database","neovim","neovim-plugin","vim"],"created_at":"2024-08-06T18:04:13.465Z","updated_at":"2025-10-30T06:23:32.465Z","avatar_url":"https://github.com/pbogut.png","language":"Vim Script","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"readme":"# vim-dadbod-ssh\n\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n\n**NeoVim** plugin that allows [vim-dadbod](https://github.com/tpope/vim-dadbod)\nconnections to remote servers through ssh.\n\nIt's actually a wrapper for existing adapters. It creates ssh tunnel using\n`ssh -L ...` and then passing changed connection url to proper adapter.\n\nIt was tested with `mysql`, I'm not sure how well it works with other\nconnections, if you are using it with other db please let me know.\n\n\n## Requirements\n\n  - **NeoVim** - Plugin is using nvim's `jobstart()` API to create and keep\n    tunnel, I'm sure it can be done for Vim 8+ as well. I would be grateful\n    for PR :heart:\n  - **Linux** or **MacOS** - adapter is using `ssh` command to connect to\n    the remote server. It is also using following commands:\n    `netstat` (Linux), `lsof` (MacOS), `grep`, `awk` and `sed`. To be more specific this command is\n    used:\n    `netstat -tuplen 2\u003e/dev/null | grep {localhost} | awk '{print $4}' | sed 's/.*://g'` (Linux)\n    `lsof -nP -iTCP -sTCP:LISTEN 2\u003e/dev/null | grep {localhost} | awk '{print $9}' | sed 's/.*://g'` (MacOS)\n\n## Installation\n\nUsing [vim-plug](https://github.com/junegunn/vim-plug):\n\n```vim\nPlug 'tpope/vim-dadbod'\n\nPlug 'pbogut/vim-dadbod-ssh'\n```\n\nOr use your favourite method / package manager.\n\n## Configuration\n\nAdapter format is quite simple, here is example for `mysql` connection:\n\n```vim\nlet g:my_db = \"ssh://sshremotehost:mysql://user:password@databasehost/db_name\"\n```\n\nDo not use `DB g:my_db = \"ssh://.....` especially in your start-up scripts, as\nthis command will create tunnel (which may take couple seconds) and assign\nmodified URL to the `g:my_db` variable (see how it works section), which will\nwork for some time but will fail if tunnel breaks and new one will have to be\nestablished.\n\nAs you can see normal connection URL is prepended with `ssh://sshremotehost:`\n\nHow to set up SSH password? Please, use public key.\nHow to set up user and port? You can do this in your `$HOME/.ssh/config`:\n\n```\nHost mydbhost-name\n  User username\n  HostName 123.123.123.123\n  Port 22222\n```\n\nWith that you can use `ssh://mydbhost-name:` in your connection string.\n\n\nTo work adapter don't need any additional configuration, but there are few\nthings one may want to adjust.\n\n\n  - `g:db_adapter_ssh_localhost` - defaults to `127.0.0.1`\n     Why IP and not just `localhost`? It is used to replace your connection host\n     and `localhost` is causing issues with `mysql` (maybe others too?). When\n     host is `localhost` `mysql` is trying to connect with socket instead of\n     network.\n  - `g:db_adapter_ssh_timeout` - defaults to `10000` (10 seconds)\n     It's how long adapter will wait for tunnel to be established.\n  - `g:db_adapter_ssh_port_range` - defaults to `range(7000, 7100)`\n     It's range of local ports that will be used to create tunnels, you can\n     specific different range. Script is checking if port is available before\n     trying to create tunnel, so if some IPs in range are taken that should be\n     fine.\n\n## So how it works?\n\nOn first connection `ssh` is used to create tunnel to the remote server. Then\nin connection URL port and host are changed to use `localhost` and port that was\nused to create tunnel. URL modified like that is then passed to the adapter.\n\nWith this URL `ssh://sshremotehost:mysql://user:password@databasehost/db_name`\nadapter will run: `ssh -L 7000:databasehost:3306 -t echo ssh_connected; read`.\nURL is modified to `mysql://user:password@127.0.0.1:7000/db_name` and that is\npassed to the `mysql` adapter.\n\n`read` is used to keep connection alive and `echo` to confirm when connection is\nestablished. `-N` could be used instead `read` but then would have to find\nanother method to confirm connection was established. If you have better ideas\nI accept PR's.\n\n## Contributions\n\nAlways welcome.\n\n## License\n\nMIT License;\nThe software is provided \"as is\", without warranty of any kind.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbogut%2Fvim-dadbod-ssh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpbogut%2Fvim-dadbod-ssh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbogut%2Fvim-dadbod-ssh/lists"}