LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Create pw randomly use binary file source (https://www.linuxquestions.org/questions/linux-security-4/create-pw-randomly-use-binary-file-source-4175733335/)

tidahot 01-29-2024 09:44 PM

Create pw randomly use binary file source
 
Was thinking of commandline way create pw randomly ussing file as source of chars instead of other random source.

Code:

#!/bin/bash
#parm1
sizebyte=$(wc -c < $1)
for ((i = 0 ; i < 7 ; i++)); do
    #grab characters random
    lines=$((1 + $RANDOM % 5))
    position=$((1 + $RANDOM % $sizebyte))
    #done
    dd skip=$position count=50 if=$1 of=/tmp/out.bin bs=1
    final+=$(tr -dc [:graph:] < /tmp/out.bin | head -c $lines)
    rm /tmp/out.bin
    #debug
    final+=" "
done
echo $final

Is seed from a binary file good source method?

Michael Uplawski 01-30-2024 12:23 AM

Is this an equivalent of what you seek ?
Code:

dinner@half_past_six:/tmp$ gpg --gen-random --armor 2 20
xq7ATzFpjRwMGXJwP63BuwaFw80=


pan64 01-30-2024 01:30 AM

A password generator need to have some input parameters, like length. See for example this: https://www.lastpass.com/features/password-generator or https://www.avast.com/random-password-generator#mac
Using a file is not really safe, depends on the file itself. Not suggested.

Michael Uplawski 01-30-2024 06:00 AM

Quote:

Originally Posted by pan64 (Post 6480192)
Using a file is not really safe, depends on the file itself. Not suggested.

Ack.
But it depends on the uses, too. I do not carry around key-files but much of the discussion on the GnuPG mailing list is about cards. People appear to need key-files.

jmccue 01-30-2024 07:53 AM

Quote:

Originally Posted by tidahot (Post 6480163)
Is seed from a binary file good source method?

Interesting, I think for your purposes it is good enough.

Since people posted other methods, here is another :)

Code:

tr -cd "[:print:]" < /dev/urandom | fold -w 16 | sed 10q
I executed your script on a remote Linux machine I have access to. The passwords generated results has spaces in the results. Is that expected ?

sundialsvcs 01-30-2024 02:59 PM

I frankly don't like "random passwords," because inevitably you put them into some kind of "keychain" which can be compromised.

To properly protect a remote system, put OpenVPN as the "outer moat," using unique digital certificates. (Also, use "tls-auth" or its equivalent.) Authorized users can cross the (hidden ...) drawbridge just by clicking an icon at the top of the screen, whereas everyone else is utterly locked-out. Furthermore, certificates can be individually "revoked" – say if a laptop gets stolen or someone leaves the company. (They can also be "password-protected," which encrypts their content.)

If, and only if, you pass over the drawbridge can you come to the (ssh ...) "portcullis" and thereby enter the castle.

pan64 01-31-2024 01:14 AM

Quote:

Originally Posted by sundialsvcs (Post 6480326)
I frankly don't like "random passwords," because inevitably you put them into some kind of "keychain" which can be compromised.

To properly protect a remote system, put OpenVPN as the "outer moat," using unique digital certificates. (Also, use "tls-auth" or its equivalent.) Authorized users can cross the (hidden ...) drawbridge just by clicking an icon at the top of the screen, whereas everyone else is utterly locked-out. Furthermore, certificates can be individually "revoked" – say if a laptop gets stolen or someone leaves the company. (They can also be "password-protected," which encrypts their content.)

If, and only if, you pass over the drawbridge can you come to the (ssh ...) "portcullis" and thereby enter the castle.

I frankly don't like hackers, data mining and in general I don't like if anybody want to play with my own private data.
I need to log in almost everywhere, including google, facebook, netflix, LQ, github, webshops, banks, package delivery companies, ... and I cannot rule them (to really protect me).
OpenVPN cannot help on this, certificates cannot help on this. They can only protect the line, but not the thing at the other end of the line.

Michael Uplawski 01-31-2024 02:59 PM

The only way that random passwords could – in my opinion – be hypothetically useful, to some extend, is to not memorize, copy or send them, then to ensure they will be destroyed on the slightest suspicion of an attack. Even waterboarding would not suffice to get the password.

I hope that not one of us is in a situation that justified anything close to this. ;)
Else, get out and do not bother with passwords in the first place.


All times are GMT -5. The time now is 07:31 AM.