LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-29-2024, 09:44 PM   #1
tidahot
LQ Newbie
 
Registered: Jan 2024
Posts: 1

Rep: Reputation: 0
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?
 
Old 01-30-2024, 12:23 AM   #2
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Is this an equivalent of what you seek ?
Code:
dinner@half_past_six:/tmp$ gpg --gen-random --armor 2 20
xq7ATzFpjRwMGXJwP63BuwaFw80=
 
Old 01-30-2024, 01:30 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
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.
 
Old 01-30-2024, 06:00 AM   #4
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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.
 
Old 01-30-2024, 07:53 AM   #5
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 691
Blog Entries: 1

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by tidahot View Post
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 ?
 
Old 01-30-2024, 02:59 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942Reputation: 3942
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.

Last edited by sundialsvcs; 01-30-2024 at 03:00 PM.
 
Old 01-31-2024, 01:14 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
Quote:
Originally Posted by sundialsvcs View Post
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.
 
Old 01-31-2024, 02:59 PM   #8
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash scripting:Difficulty with binary executables Cannot execute binary file USE:acpi lock+suspend Adhil Linux - Software 10 03-17-2018 08:31 PM
.oui: cannot execute binary file .oui: cannot execute binary file .oui kazi9822 Linux - Server 18 09-28-2012 04:44 PM
Linux utility to combine two or more binary files into a single binary file mageshvan Programming 7 05-05-2011 08:06 AM
Help: Opening GenICs binary file, writing to binary file for GADGET-2 (in C) parallax147 Programming 0 10-05-2010 11:06 AM
Do I need binary 1 and binary 2 dvd iso for base install? salah-ad-din Debian 5 08-15-2006 04:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration