Created
March 6, 2023 13:38
-
-
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 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') | |
echo '#!/bin/bash' | sudo tee /usr/local/bin/sudopwd | |
echo "op.exe item get $oppassid --fields label=password" | sudo tee -a /usr/local/bin/sudopwd # also verify the field is correctly named | |
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