Skip to content

Instantly share code, notes, and snippets.

@mahmoudimus
Forked from matfax/.zshrc
Created March 24, 2024 15:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoudimus/6279c1978abf08380521e064d7439a28 to your computer and use it in GitHub Desktop.
Save mahmoudimus/6279c1978abf08380521e064d7439a28 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