Skip to content

Instantly share code, notes, and snippets.

@subnut
Created February 7, 2022 14:06
Show Gist options
  • Save subnut/1da1a4fe9c4b1836f7672b0df19a7b5b to your computer and use it in GitHub Desktop.
Save subnut/1da1a4fe9c4b1836f7672b0df19a7b5b to your computer and use it in GitHub Desktop.
ssh-askpass using zenity
#!/bin/sh
## Logging purposes
# PREVDIR=`pwd`
# cd "$(dirname "$0")"
# exec 1>./log.txt
# exec 2>./log_err.txt
# echo '$PREVDIR:' "$PREVDIR"
# echo '$1:' "$1"
# env | grep ^SSH_
# Zenity interprets a single underscore as the 'mnemonic character'
# To print a single underscore, we need to have two underscores in the --text
# See: https://bugzilla.redhat.com/show_bug.cgi?id=1696157
TEXT="$(echo "$1" | sed s/_/__/g)"
if [ "$SSH_ASKPASS_PROMPT" = confirm ]
then zenity --text="$TEXT" --title=ssh-askpass --question
else zenity --text="$TEXT" --title=ssh-askpass --entry --hide-text
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment