Skip to content

Instantly share code, notes, and snippets.

@normanr
normanr / netrc-askpass
Last active April 30, 2023 20:36
read sftp password from .netrc
#!/bin/bash
# Usage: SSH_ASKPASS_REQUIRE=force SSH_ASKPASS=netrc-askpass sftp ...
if [[ $1 =~ ([[:graph:]]+)@([[:graph:]]+)\'s\ password: ]]; then
USER="${BASH_REMATCH[1]}"
HOST="${BASH_REMATCH[2]}"
state=token
while read -a WORDS; do
for WORD in ${WORDS[@]}; do
case $state in
token)