Skip to content

Instantly share code, notes, and snippets.

@SimonLammer
Created August 12, 2023 13:38
Show Gist options
  • Save SimonLammer/ac0da816617efd42f626c9157523f80c to your computer and use it in GitHub Desktop.
Save SimonLammer/ac0da816617efd42f626c9157523f80c to your computer and use it in GitHub Desktop.
Read password from stdin into keyctl
# probably want to start a new session, so the key is removed once the script closes
keyctl new_session >/dev/null
# read tye key into keyctl
stty -echo
echo -n "Enter ssh password: "
password_key=$(read -s password && echo -n "$password" | keyctl padd user pw @s)
stty echo
echo ""
# pipe the key to some program
keyctl pipe "$password_key" | cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment