Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreynaydenov/ssh_to_nb_device
A script to streamline SSH access to network devices by integrating NetBox, Bitwarden, and fzf
https://github.com/andreynaydenov/ssh_to_nb_device
bitwarden fzf netbox network-automation ssh sshpass
Last synced: 16 days ago
JSON representation
A script to streamline SSH access to network devices by integrating NetBox, Bitwarden, and fzf
- Host: GitHub
- URL: https://github.com/andreynaydenov/ssh_to_nb_device
- Owner: AndreyNaydenov
- Created: 2025-01-13T21:35:53.000Z (25 days ago)
- Default Branch: main
- Last Pushed: 2025-01-17T14:33:25.000Z (21 days ago)
- Last Synced: 2025-01-17T15:40:50.934Z (21 days ago)
- Topics: bitwarden, fzf, netbox, network-automation, ssh, sshpass
- Language: Shell
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Objective:
Create a script to perform the following tasks:1. **Retrieve Device Information**
Fetch device details from NetBox.
2. **Select Device**
Display the retrieved devices using `fzf` (a command-line fuzzy finder) for easy selection.
3. **Fetch Credentials**
Access the corresponding credentials for the selected device from Bitwarden.
4. **Select Credential**
Use `fzf` to display and choose the appropriate credential from the retrieved list.
5. **Connect via SSH**
Establish an SSH connection to the selected host through a jump host, using the chosen credentials (password-based authentication).## Dependencies:
- sshpass - to use SSH interactive password in non-interactive manner
- bitwarden-cli - to get passwords
- jq - to get credential names from BitWarden
- nbcli - to get list of devices and addresses
- fzf - to provide choose interface for user
- ssh - to connect
- NOC host as a jumphost## Install:
0. make sure that you have jq, bw, sshpass, fzf and python3 installed
1. make python venv ```python3 -m venv venv```
2. activate venv ```. ./venv/bin/activate```
3. install requirements ```pip install -r requirements.txt```
4. run ```nbcli init```
5. edit pynetbox 'url' and 'token' entries in user_config.yml: ~/.nbcli/user_config.yml
6. unlock BW vault ```bw unlock``` and export BW_SESSION key shell variable
7. make sure that you have "nbcli" and "sshdevicepass" in PATH (I have made softlinks to ~/.local/bin)
8. run ```sshdevicepass```## TODO:
- Add nbcli results caching (call to nbcli takes a long time)