Saturday, February 15, 2014

pwgen Script - Linux


A simple script I created that asks a character length and outputs random characters to use as a password. The script uses pwgen. (Password generator) This is useful if you're using Openbox and want pwgen on the right click menu, or have a hard time remembering the command. You will be asked how long long you want the password to be, then it will display a random output with special characters included.

Video tutorial/in action: Here

1. Open Terminal and enter:
sudo apt-get install pwgen
2. Followed by 
touch ~/script.sh && chmod +x ~/script.sh
3. Open the file manager. Right click on script.sh, go to Open with and select your editor.

4. Add this in, then save and close.
#clear   #Used if opened from the terminal
read -p "Character Length: " number
clear
echo
echo
pwgen -y -1 "$number"
echo
echo
5. The script can be opened in the terminal.
sh ~/script.sh

Using Openbox's menu to execute the script
1. In the terminal type:
obmenu
2. Enter a name for the label. (This is what shows up when you right click) I used pwgen.

3. Add this to Execute at the bottom
terminator --command="sh ~/script.sh; echo; ${SHELL:-bash}"
Replace ~/script.sh to the location and file name of your choice

4. Click Save at the top. Right click on the desktop, then select pwgen to launch the script.

No comments:

Post a Comment