gotty icon indicating copy to clipboard operation
gotty copied to clipboard

Added support for basic authentication with custom script

Open moisespsena opened this issue 7 years ago • 0 comments

Added support for basic authentication with custom script.

Generate linux system authentication script from template (see content below):

gotty --sys-auth-tpl > ./auth.sh
chmod +x ./auth.sh

NOTE: this script requires root access (or sudo).

Usage example:

sudo gotty --authenticator ./auth.sh top

Access web page and login with your linux username and password.

Content of ./auth.sh:

#!/bin/bash

# #### REQUEST INFO ####
# echo REQUEST INFO:
# json_pp

username="$1"
password="$2"

salt=$(getent shadow $username | cut -d$ -f3)
epassword=$(getent shadow $username | cut -d: -f2)

match=$(python -c 'import crypt; print crypt.crypt("'"$password"'", "$6$'$salt'")')

if [ "$match" == "$epassword" ]; then
  # success
  exit 0
fi

# failed
exit 1

moisespsena avatar Dec 20 '18 19:12 moisespsena