{"id":25249582,"url":"https://github.com/andreiyard/ssh_to_nb_device","last_synced_at":"2025-04-05T21:44:11.168Z","repository":{"id":272939572,"uuid":"916318122","full_name":"andreiyard/ssh_to_nb_device","owner":"andreiyard","description":"A script to streamline SSH access to network devices by integrating NetBox, Bitwarden, and fzf","archived":false,"fork":false,"pushed_at":"2025-01-17T14:33:25.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T03:23:49.256Z","etag":null,"topics":["bitwarden","fzf","netbox","network-automation","ssh","sshpass"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/andreiyard.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":"2025-01-13T21:35:53.000Z","updated_at":"2025-01-17T14:33:26.000Z","dependencies_parsed_at":"2025-01-17T15:40:55.201Z","dependency_job_id":"9334f37f-49c8-4dc4-bdee-dde285a5b14a","html_url":"https://github.com/andreiyard/ssh_to_nb_device","commit_stats":null,"previous_names":["andreynaydenov/ssh_to_nb_device","andreiyard/ssh_to_nb_device"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiyard%2Fssh_to_nb_device","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiyard%2Fssh_to_nb_device/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiyard%2Fssh_to_nb_device/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreiyard%2Fssh_to_nb_device/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreiyard","download_url":"https://codeload.github.com/andreiyard/ssh_to_nb_device/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406068,"owners_count":20933802,"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":["bitwarden","fzf","netbox","network-automation","ssh","sshpass"],"created_at":"2025-02-12T03:22:39.427Z","updated_at":"2025-04-05T21:44:11.143Z","avatar_url":"https://github.com/andreiyard.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Objective:\nCreate a script to perform the following tasks:\n\n1. **Retrieve Device Information**  \n   Fetch device details from NetBox.\n2. **Select Device**  \n   Display the retrieved devices using `fzf` (a command-line fuzzy finder) for easy selection.\n3. **Fetch Credentials**  \n   Access the corresponding credentials for the selected device from Bitwarden.\n4. **Select Credential**  \n   Use `fzf` to display and choose the appropriate credential from the retrieved list.\n5. **Connect via SSH**  \n   Establish an SSH connection to the selected host through a jump host, using the chosen credentials (password-based authentication).\n\n## Dependencies:\n\n- sshpass - to use SSH interactive password in non-interactive manner\n- bitwarden-cli - to get passwords\n- jq - to get credential names from BitWarden\n- nbcli - to get list of devices and addresses\n- fzf - to provide choose interface for user\n- ssh - to connect\n- NOC host as a jumphost\n\n## Install:\n\n0. make sure that you have jq, bw, sshpass, fzf and python3 installed\n1. make python venv ```python3 -m venv venv```\n2. activate venv ```. ./venv/bin/activate```\n3. install requirements ```pip install -r requirements.txt```\n4. run ```nbcli init```\n5. edit pynetbox 'url' and 'token' entries in user_config.yml: ~/.nbcli/user_config.yml\n6. unlock BW vault ```bw unlock``` and export BW_SESSION key shell variable\n7. make sure that you have \"nbcli\" and \"sshdevicepass\" in PATH (I have made softlinks to ~/.local/bin)\n8. run ```sshdevicepass```\n\n## TODO:\n\n- Add nbcli results caching (call to nbcli takes a long time)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreiyard%2Fssh_to_nb_device","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreiyard%2Fssh_to_nb_device","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreiyard%2Fssh_to_nb_device/lists"}