Computer Love > Servers

Create Your Own Password Genetator In Bashrc!

(1/1)

Skhilled:
No more going to other sites to generate random passwords! Just add the following code below to bashrc. In any SSH terminal use the following code to find out where bashrc resides:


--- Code: ---whereis bashrc
--- End code ---

Open it in your favorite editor and add the following code to the bottom of the file:


--- Code: ---function pass()
{
    if [ "$#" -ne 1 ]; then
        count=15
    else
        count=$1
    fi

    pass=`</dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${count}`
    echo $pass
}
--- End code ---

Reboot your session then type "pass" which will give you a random 15 character password. You can change the length of the password by specifying a parameter such as "pass 20" which will generate a random 20 character password.

Oldcrow:
How is this done? Where is bashrc

Skhilled:
You must type in "whereis bashrc" in SSH and it will tell you exactly where the file is on your server. You will then have two options...

1.  If your control panel (WHM/cpanel, etc.) allows you to access and edit files you can locate it and edit it there. If you can't, there are tools/addons to allow you to do this.

2.  Use a good ssh/putty tool like MobaXterm. It also has options to view your files on the server as well as choosing a default editor to edit and save them. ;)

Navigation

[0] Message Index

Go to full version