OpenSUSE Linux Tips, tricks, how-tos, opinions, and news
My Resume - My LinkedIn ProfileWhen you have the level of paranoia that I do, being able to generate ultra-secure passwords is a very nice thing.
My bash prompt is also something I take great pride in. Not only that, I really like it.
Well guess what, folks… you can do both with the same file. This would be your .bashrc file. Here’s a basic look at my prompt:
[1850][scott@laptop:~]$
It shows me the time, the account with which I am logged in, the hostname of the local machine, and the present working directory. All handy things to know.
Now, for the password generation thing, check this out:
[1855][scott@laptop:~]$ genpasswd 64 (#b-p>yi>ojSw@oS6PN,uo_A`;.}DuyfG{levk[Q$UgfrmAkE^t|&)dZb!Nry; [1855][scott@laptop:~]$
You can make rainbow tables ’til the end of time, and let John the Ripper go on the /etc/shadow file with that password in it, and you ain’t gonna be cracking that password.
If this is interesting to you, or you have other suggestions of a similar nature, please, let’s have ’em.
That all said, here’s the .bashrc file that makes this prompt and password generator possible:
# /etc/skel/.bashrc: # This file is sourced by all *interactive* bash shells on startup. This # file *should generate no output* or it will break the scp and rcp commands. # colors for ls, etc. eval `dircolors -b /etc/DIR_COLORS` alias d="ls --color" alias ls="ls --color=auto" alias ll="ls -al --color" # Change the window title of X terminals case $TERM in xterm*|rxvt|Eterm|eterm) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"' ;; screen) PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"' ;; esac ##uncomment the following to activate bash-completion: #[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion function proml { local BLUE="\[\033[0;34m\]" local RED="\[\033[0;31m\]" local LIGHT_RED="\[\033[1;31m\]" local WHITE="\[\033[1;37m\]" local LIGHT_GRAY="\[\033[0;37m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="${TITLEBAR}\ $BLUE[$RED\$(date +%H%M)$BLUE]\ $BLUE[$LIGHT_RED\u@\h:\w$BLUE]\ $WHITE\$$LIGHT_GRAY " PS2='> ' PS4='+ ' } proml alias ifconfig="/sbin/ifconfig" genpasswd() { local l=$1 [ "$l" == "" ] && l=20 tr -dc A-Za-z0-9\-_~\!@#$%^\&*\(\)\\\`\+\[\{\]\}\|\;:\",\<.\>/?\= < /dev/urandom | head -c ${l} | xargs }
Hope that's as useful for you as it has been for me.
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
« Feb | ||||||
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
62 queries. 0.816 seconds
July 29th, 2009 at 12:17 am
Hi Scott,
I use `pwgen` for creating secure passwords on the command line: http://sourceforge.net/projects/pwgen/ It’s available in the default openSUSE repositories.
(And like you, I have the time as part of my prompt – really good for seeing when you executed a command or roughly how long a command took to execute).
Cheers,
Henare
July 30th, 2009 at 2:34 am
hm. i don’t get it. nobody will ever crack that password, but nobody will ever remember it either?
October 5th, 2009 at 9:50 am
this kind of passwords are very good if you don’t want to remember :), but also when you need to encrypt a high secure information, then you can printed and lockdown in a bank or something similar.