Last active
March 12, 2024 20:15
-
-
Save onnyyonn/2139bc673191cdf97ca2cd2d095abf26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env nix-shell | |
| #! nix-shell -i bash -p git bitwarden-cli jq | |
| # This script downloads my SSH key from Bitwarden and then clones my private NixOS config repository from Github | |
| # Assumptions: | |
| # 1. You have only one item named "SSH Keys" stored in Bitwarden | |
| # 2. The private key is saved in that item as an attachment named "id_rsa" | |
| # 3. The public key is added to Github account | |
| mkdir -p ~/.ssh | |
| if ! bw login --check > /dev/null | |
| then | |
| BW_SESSION="$(bw login --raw)" | |
| else | |
| BW_SESSION="$(bw unlock --raw)" | |
| fi | |
| export BW_SESSION | |
| BW_ID="$(bw list items --search "SSH Keys" | jq -r ".[] | select(.name==\"SSH Keys\").id")" | |
| bw get attachment id_rsa --itemid ${BW_ID:1:20} --output ~/.ssh/id_rsa | |
| git clone [email protected]:onnyyonn/nix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment