Skip to content

Instantly share code, notes, and snippets.

@matfax
Created March 6, 2023 13:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matfax/8853783a56aa886d7019d7b8024437ad to your computer and use it in GitHub Desktop.
Save matfax/8853783a56aa886d7019d7b8024437ad to your computer and use it in GitHub Desktop.
Sudo authentication with Windows 1Password CLI on Ubuntu WSL
# ....
alias sudo="sudo -A"
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
# ....
Path askpass /usr/local/bin/sudopwd
#!/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