#!/bin/bash key="/dev/shm/${0##*/}" pubkey="${key}.pub" onetime_suffix="-OTA" authfile=.ssh/authorized_keys password="" test -r "${0}.conf" && source "${0}.conf" test -w "$authfile" || exit sed -i "/ \+${0##*/}-$onetime_suffix *$/d" "$authfile" if test -z "$1"; then rm -f "$key" "$pubkey" password+=$(head /dev/urandom | sum | cut -d' ' -f1) ssh-keygen -qf "$key" -P "$password" -C "${0##*/}$onetime_suffix" || exit echo "command=\"$0 one-time-key\" $(<$pubkey)" >> "$authfile" cat "$key" >&2 ${0%%/*}/smsapi "code clé: $password" rm -f "$key" "$pubkey" else zsh -i fi