Random Passwords


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Random Passwords
# 1  
Old 03-05-2015
Random Passwords

Hi Friends,

I need a quick help in unix scripts,

my aim is to generate random passwords like,

1. first 3 characters are alphabets or numbers
2. then one of special characters like &()/?:;+-
3. Last 4 characters are alphabets or numbers

total length will be 8.

i tried with urandom option but cant help..

Is there any one can help me on this, how to get the same ?.

Regards,
Nantha.
# 2  
Old 03-05-2015
This is a bash example:

Code:
#!/bin/bash

alnum="0123456789abcdefjhijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ"
punct="!@#$%^&*<>.,:;><{}[]"
len1=${#alnum}
len2=${#punct}
pwd=""
tmp=""
pun=""
for((i=0; i<8 ; i++))
do
   n=$(( $RANDOM % len1 ))
   tmp=$tmp${alnum:$n:1}
   n=$(( $RANDOM % len2 ))
   pun=$pun${punct:$n:1}
done
pwd=${tmp:0:4}${pun:0:4}${tmp:4}
echo "$pwd"

You would be far better off to find a password generator on the net.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

2. UNIX for Advanced & Expert Users

When did UNIX start using encrypted passwords, and not displaying passwords when you type them in?

I've been using various versions of UNIX and Linux since 1993, and I've never run across one that showed your password as you type it in when you log in, or one that stored passwords in plain text rather than encrypted. I'm writing a script for work for a security audit, and two of the... (5 Replies)
Discussion started by: Anne Neville
5 Replies

3. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

4. Shell Programming and Scripting

passwords

Dear all, I need to automate/script a user password change process. I'm helpless cannot use expect since it's not installed and cannot install it either. Do i have an alternative. I can store the password in a file and that would be the password that would be set to all the users. If not i don't... (1 Reply)
Discussion started by: earlysame55
1 Replies

5. UNIX for Dummies Questions & Answers

A shell script or software for generating random passwords

Hi, Is there an shell script/batch file to genarate random passwords which expires after a stipulated time period? Please suggest a software which does this for AIX and windows both else. Thanks. (5 Replies)
Discussion started by: dwiravi
5 Replies

6. UNIX for Dummies Questions & Answers

A shell script or any software to genarate random passwords

Hi, Is there a shell script or any software to genarate random passwords and the passwords expire automatically after a stipulated time period. Please suggest. (2 Replies)
Discussion started by: dwiravi
2 Replies

7. Windows & DOS: Issues & Discussions

A software or a batch file to genarate random passwords

Hi, Is there a batch file or any software to genarate random passwords and the passwords expire automatically after a stipulated time period. Please suggest. (1 Reply)
Discussion started by: dwiravi
1 Replies

8. UNIX for Dummies Questions & Answers

sqlplus and passwords

Hope I'm in the right place to ask this. ... and I'm a total noob by the way. When changing an account password through telnet, everything seems fine. I can telnet back in afterward, but if I try to use sqlplus to get in it tells me password invalid. If I try to get in through sqlplus with the... (1 Reply)
Discussion started by: tazman4
1 Replies

9. UNIX for Dummies Questions & Answers

Passwords

I am running unix 11.xxx....How do you change a user password. The previous vs was passwd at the command prompt. This no longer works. Thanks for the help (3 Replies)
Discussion started by: turner.rd
3 Replies
Login or Register to Ask a Question