coder / wush

simplest & fastest way to transfer files between computers via WireGuard
Creative Commons Zero v1.0 Universal
891 stars 24 forks source link

pipe Auth ID to wush ssh #26

Closed amigthea closed 1 month ago

amigthea commented 2 months ago

how can I directly pipe the auth id to wush commands without explicitly insert it by user input?

gdmn commented 2 months ago
TEMP_DIR="$(mktemp -d)"
mkfifo $TEMP_DIR/auth
wush serve | while read l; do
    echo "$l" >> $TEMP_DIR/auth
done &
AUTH="$(cat $TEMP_DIR/auth)"
echo "auth: $AUTH"
wait

and then you can use $AUTH variable for other commands

e.g.

wush ssh "--auth-key=$AUTH"

I wrote 2 scripts that help me with that. First one can automatically start wush serve and notify about the auth key via ntfy: https://github.com/gdmn/scripts/blob/master/wush-serve.sh. Then those keys are put in a file and can be used for ssh-ing into hosts: https://github.com/gdmn/scripts/blob/master/wush-ssh.sh.

coadler commented 1 month ago

Going to close, @gdmn's option seems to be the best here. We won't be able to accept the auth key via stdin because we'll need to attach that to the tty for input.