added first pubkey automation for yubikey

This commit is contained in:
Marco Raber 2022-06-11 16:23:55 +02:00
parent 9241d2f96d
commit 9b60386710

18
sshin
View File

@ -14,6 +14,12 @@ IP_PREFIX="192.168.1."
[[ $# -le 1 ]] && usage && exit 1
[[ $1 = "-h" ]] && usage -h && exit 1
re='^[0-9]+$'
USUAL_PUBKEY=~/.ssh/id_rsa
YUBIKEY_PUBKEY=~/.ssh/id_ed25519_sk
HOSTS_FILE=~/.local/share/sshin/hosts
command="ssh ${1}@"
shift
if [[ $1 =~ $re ]]
@ -27,5 +33,17 @@ else
dport=$(grep $1 $ports_file | awk '{print $NF}')
[[ -n $port ]] && command="${command} -D$dport"
fi
#check if Yubikey is present
lsusb | grep -q "Yubico" && YUBIKEY_PRESENCE=1 || YUBIKEY_PRESENCE=0
#check if the host you are connecting to has Yubikey support (both client and server need openssh >= 8.2)
YUBIKEY_SUPPORT=$(cat $HOSTS_FILE | grep $1 | awk '{print $2}')
[[ $YUBIKEY_SUPPORT = "" ]] && echo "vuoto" && YUBIKEY_SUPPORT=0
[[ $YUBIKEY_PRESENCE -eq 1 ]] && [[ $YUBIKEY_SUPPORT -eq 1 ]] && command="${command} -i $YUBIKEY_PUBKEY" || command="${command} -i $USUAL_PUBKEY"
echo $command
#echo $YUBIKEY_SUPPORT
$command