Last active
July 21, 2025 13:16
-
-
Save matfax/8853783a56aa886d7019d7b8024437ad to your computer and use it in GitHub Desktop.
Sudo authentication with Windows 1Password CLI on Ubuntu WSL
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
# .... | |
alias op="op.exe" | |
eval "$(op completion zsh)"; compdef _op op.exe | |
alias sudo="sudo -A" |
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
sudo apt update && sudo apt install jq # jq is only necessary for selecting the ID from op json output, which can as well be done manually | |
oppassid=$(op item get 'your 1Password item name/identity' --format json | jq -r '.id') | |
sudo tee -a /usr/local/bin/sudopwd <<EOF | |
#!/bin/bash | |
op.exe item get $oppassid --reveal --fields label=password | |
EOF | |
sudo chmod +x /usr/local/bin/sudopwd | |
cp ~/.zshrc ~/.zshrc.bak # backup zshrc, or bashrc | |
echo 'alias sudo="sudo -A"' >> ~/.zshrc # or bashrc | |
echo 'Path askpass /usr/local/bin/sudopwd' | sudo tee -a /etc/sudo.conf |
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
# .... | |
Path askpass /usr/local/bin/sudopwd |
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
#!/bin/bash | |
op.exe item get the_id_of_your_secret --fields label=password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment