Linux Lite Forums

Development => Scripting and Bash => Topic started by: bitsnpcs on January 31, 2018, 01:52:04 PM

Title: Random Passwords Anyone ?
Post by: bitsnpcs on January 31, 2018, 01:52:04 PM
Hello,

here is a function for making random passwords. It works for the session you are in, and will need re-adding in a new session, eg you can close and open terminal and randpw will work but if you reboot you need to re-add the function.

Code: [Select]
randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;}
If you copy/paste this (or type it) into your terminal and hit enter.

Every time you need a new random password open your terminal and type

Code: [Select]
randpw
and it will generate one and save you having to type the entire function out again that session.

An example -

(https://preview.ibb.co/ciwppR/pw.png)

Be sure to save any random passwords you use somewhere safe, like the password locker/safe, didn't we used to have one of these in Linux Lite ?

I will post some other ways to do this soon.
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on January 31, 2018, 01:59:55 PM
Another way to do this but without saving it as a function, eg; you will need to type it in each time.

Is to type into your terminal

Code: [Select]
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
An example

(https://preview.ibb.co/itwsb6/screen2.png)

Coz reverse stuff can be fun, lets do it in reverse -

Code: [Select]
tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1
An example

(https://preview.ibb.co/kWDc9R/screen3.png)

More to come
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on January 31, 2018, 02:04:37 PM
We may want to add the randomness to our username -

Code: [Select]
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6
Copy/paste (or type it in to your terminal) hit enter -

An example

(https://preview.ibb.co/fVsepR/screen4.png)
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on January 31, 2018, 02:08:28 PM
Just need it quick -

Code: [Select]
date | md5sum
An example

(https://preview.ibb.co/fXoKpR/screen5.png)
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on January 31, 2018, 02:27:51 PM
Another simple way to make a password is to type in to your terminal the command -

Code: [Select]
rev
Now type in some text and hit enter, this will reverse the text, it may give some ideas for passwords.

To exit the command hold down Ctrl Key and press Z key to return to your prompt.

Hope they were fun, interesting and of use for someone. :)
Title: Re: Random Passwords Anyone ?
Post by: ian_r_h on February 01, 2018, 07:45:41 AM
You know, I am beginning to love the terminal...!  :D
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 01, 2018, 12:43:54 PM
You know, I am beginning to love the terminal...!  :D
:)

I'll add a couple more, and then some other fun ones in another thread soon.
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 01, 2018, 02:52:35 PM
Hold down Ctrl and Alt keys and press t (Ctrl Alt + t)
Copy/paste (or type) in to your terminal -

Code: [Select]
openssl rand -base64 32
An example

(https://preview.ibb.co/kUsCDm/openssl.png)
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 01, 2018, 02:58:23 PM
Hold down Ctrl and Alt keys and press t (Ctrl Alt + t)
Copy/paste (or type) in to your terminal -

Code: [Select]
date +%s | sha256sum | base64 | head -c 32 ; echo
An example

(https://preview.ibb.co/mMa2eR/sha256.png)
Title: Re: Random Passwords Anyone ?
Post by: ian_r_h on February 02, 2018, 07:22:41 AM
To answer the question I missed that you posed, KeypassX is available in the Lite Software list I believe - I use that myself as a password store.

My plan for this year is to continue working through the Linux Bible, and then move onto learning the depths of the terminal from Beginning the Linux Command Line.  (Both references below, should anyone want to explore the two books.)

Thanks to everyone here for LL - I've fallen in love with computing again.  Assuming use of the term "computing" doesn't betray my age!  Trying to convince friends and family to give LL a go, now that they are finding Windows 10 hard-going!   ;D

Negus, Christopher.  2015.  Linux Bible (9th Ed.)  Wiley.  ISBN 978-1-118-99987-5.
Van Vugt, Sander.  2009.  Beginning the Linux Command Line.  Apress.  ISBN 978-1-4302-1889-0.
(New versions of each may be available.)
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 02, 2018, 08:46:20 AM
Hello @ian_r_h ,

thank you for the answer about KeypassX  :)

Are you using the Linux Bible with RHEL, Fedora, or Ubuntu Gnome, as its wrote for these, or another distro ?
I didn't get far with it, Chapter 2 Gnome Extensions, it kept asking for the root password and wouldn't accept it, unsure what mistake I made, so I have removed it from VirtualBox and have not gotten around to putting it back to try again yet.

Update -
I have reinstalled Fedora27 workstation, in VirtualBox on Linux Lite this morning, and have found where I went wrong on the install.
So have managed to get the browser and install working on Fedora and the Gnome extensions is working, and I've added some menus, top and bottom panel, and changed the workspace switcher, as in the book.
Not in the book also done 1366 updates, including the kernel and headers.
The book sort of misses out all of this, and skips to using the Gnome extensions.

Cannot get the run script to work for the guest additions, as it says it needs to be installed in Fedora guest not on the host machine, so its next one to work on. This is also not covered in the book.
It means I have managed to get .......... 2 pages further in Chapter 2 of the book now :) , not much but I'm still happy for the movement, I am where it says to jump to Chapter 10 for installing some stuff. :o
(Maybe guest additions is covered there)

Update 2 -
have got the guest additions installed now. :)
done the clone, and some installs. Moving forward a tiny bit quicker now.
 
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 02, 2018, 03:42:17 PM
Hold down Ctrl and Alt keys and press t (Ctrl Alt + t)
Copy/paste (or type) in to your terminal -

Code: [Select]
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo
An example

(https://preview.ibb.co/jitHZR/strings.png)
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 02, 2018, 03:47:37 PM
Hold down Ctrl and Alt keys and press t (Ctrl Alt + t)
Copy/paste (or type) in to your terminal -

Code: [Select]
dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev
An example

(https://preview.ibb.co/hgeXZR/dd1.png)
Title: Re: Random Passwords Anyone ?
Post by: ian_r_h on February 03, 2018, 07:21:47 AM
I'm just working through the book without working through the examples, at the moment.  That's kind of how I learn - an initial read and a break, so my mind consolidates things.

LL is my only distro at this time.  I guess I'm still at the "getting a feel for" stage with Linux.  But so far I really like Linux!

BTW, what's the @username thing in the forum??
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 03, 2018, 10:03:08 AM
Hello ian_r_h,

with learning it is always best to do what works well for you, being settled/comfortable seems to me to be  a very big part of learning :)

LL is the only distro I use every day, I no longer use Windows, which is just since January, but it was a big step to take for me, it has taken me 3 years to get to take that step lol.

The @username thing , if a member has email notifications set up in their profile, it sends them an email saying they were "mentioned in a post"
Also in your forum profile, you can click a menu on the left side, that is named "Mentions", to find any posts where you were mentioned this way.
It's useful because the forum is a very busy place.
Title: Re: Random Passwords Anyone ?
Post by: ian_r_h on February 05, 2018, 06:07:35 AM
Thank you.

I'm pretty much now all-Linux Lite, as I haven't dared update my Windows 7 desktop for over a year (if it goes wrong, it's pretty much a 40 mile taxi round-trip to the local shop); and Windows 10 is getting more and more of a Prima Donna over updates.  And this forced updates thing is a complete nuisance - especially since the "Pro" version doesn't defer them properly on mine any more.

LL is just so much more flexible.  Plus already I can usually either fix any issues without help; or with the friendly help here!  :)
Title: Re: Random Passwords Anyone ?
Post by: bitsnpcs on February 05, 2018, 06:17:24 PM
Hello ian_r_h,

you are Welcome  :)