Skip to main content
include some recommendation of G-Man
Source Link
Boop
  • 111
  • 5

I don't see a "quick and dirty" answer, so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$useru="$user" -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "%s" "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echoprintf "%s" "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a one-liner that returns 0 if the supplied password is correct.

You need three things:

  1. Set the variable "$user"
  2. Ensure that the user exists in the /etc/shadow (e.g., if ! grep -q $user /etc/shadow; then return 1; fi)
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if the generated string matches the stored one

I don't see a "quick and dirty" answer, so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echo "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a one-liner that returns 0 if the supplied password is correct.

You need three things:

  1. Set the variable "$user"
  2. Ensure that the user exists in the /etc/shadow (e.g., if ! grep -q $user /etc/shadow; then return 1; fi)
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if the generated string matches the stored one

I don't see a "quick and dirty" answer, so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "%s" "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(printf "%s" "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a one-liner that returns 0 if the supplied password is correct.

You need three things:

  1. Set the variable "$user"
  2. Ensure that the user exists in the /etc/shadow (e.g., if ! grep -q $user /etc/shadow; then return 1; fi)
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if the generated string matches the stored one
Tweaked wording and punctuation.
Source Link

I don't see a quick"quick and "dirty" solutiondirty" answer, so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echo "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a onelinerone-liner that return 0 if suppliedreturns 0 if the supplied password is correct.

You need 3three things:

  1. Set the variable "$user"
  2. Ensure userthat the user exists in the /etc/shadow (e.g.:, if ! grep -q $user /etc/shadow; then return 1 1; fi)
  3. Set the variable "$user"
  4. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if the generated string matchmatches the stored one

hth

I don't see a quick and "dirty" solution so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echo "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a oneliner that return 0 if supplied password is correct.

You need 3 things:

  1. Ensure user exists in the /etc/shadow (e.g.: if ! grep -q $user /etc/shadow; then return 1 fi)
  2. Set the variable "$user"
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if generated string match the stored one

hth

I don't see a "quick and dirty" answer, so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echo "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a one-liner that returns 0 if the supplied password is correct.

You need three things:

  1. Set the variable "$user"
  2. Ensure that the user exists in the /etc/shadow (e.g., if ! grep -q $user /etc/shadow; then return 1; fi)
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if the generated string matches the stored one
add a perl version
Source Link
Boop
  • 111
  • 5

I don't see a quick and "dirty" solution so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echo "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

It'sIn both case, it's a oneliner andthat return 0 if supplied password is correct.

You need 3 things:

  1. Ensure user exists in the /etc/shadow (e.g.: if ! grep -q $user /etc/shadow; then return 1 fi)
  2. Set the variable "$user"
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if generated string match the stored one

hth

I don't see a quick and "dirty" solution so I'll post my solution:

One line

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

It's a oneliner and return 0 if supplied password is correct

You need 3 things:

  1. Ensure user exists in the /etc/shadow (e.g.: if ! grep -q $user /etc/shadow; then return 1 fi)
  2. Set the variable "$user"
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if generated string match the stored one

hth

I don't see a quick and "dirty" solution so I'll post my solution:

One line

openssl recent enough

userline=$(sudo awk -v u=$user -F: 'u==$1 {print $2}' /etc/shadow); IFS='$'; a=($userline); [[ "$(printf "${pass}"|openssl passwd -"${a[1]}" -salt "${a[2]}" -stdin)" = "${userline}" ]]

with perl

user="user1";pass="eeeeee";userline="$(awk -v u="$user" -F: 'u==$1 {print $2}' /etc/shadow)"; a="$(echo "$userline"|grep -Eo '^\$.*\$.*\$')"; [[ "$(perl -e "print crypt('${pass}', '${a}')")" = "${userline}" ]]

In both case, it's a oneliner that return 0 if supplied password is correct.

You need 3 things:

  1. Ensure user exists in the /etc/shadow (e.g.: if ! grep -q $user /etc/shadow; then return 1 fi)
  2. Set the variable "$user"
  3. Set the variable "$pass"

Some explanations

  1. First get the shadow line of the user
  2. Split it on $
  3. Use the openssl command to generate the string from the supplied password
  4. Check if generated string match the stored one

hth

Source Link
Boop
  • 111
  • 5
Loading