Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Shell program with username and password Post 302399463 by hakermania on Sunday 28th of February 2010 08:14:54 AM
Old 02-28-2010
Code:
#!/bin/bash
clear
echo "          		1 = Login

      			2 = Change the Login Password

			3 = Forgot your password?

			4 = Set the recall answer to question
"
	read number
	case $number in
	1)
	      if [ -s /home/alex/Documents/PASS/password_PASS ]; then
			    existpass=`cat /home/alex/Documents/PASS/password_PASS`
			    echo "Type the existing pass:"
			    read givenpassasexisted
		         if [ "$existpass" = "$givenpassasexisted" ]; then
			  	clear; echo "Success!"
		         else    	echo "Bad" 
			          exit
			 fi
		else echo "There is no password."
		
	fi;;
		
	2)
		   if [ -s /home/alex/Documents/PASS/password_PASS ]; then
			    existpass=`cat /home/alex/Documents/PASS/password_PASS`
			    echo "Type the existing pass:"  
				read givenpassasexisted
		         if [ "$existpass" = "$givenpassasexisted" ]; then
				echo "Type new password:"
				read newpass
				echo "Type again to confirm:"
				read newpass2
				if [ "$newpass" = "$newpass2" ]; then
		  		cd /home/alex/Documents/PASS/
				rm password_PASS
				echo $newpass > /home/alex/Documents/PASS/password_PASS
				echo $newpass > /home/alex/Documents/PASS/bringagain_PASS
				else clear; echo "Confirmation failure!"; exit
				fi
			else
				clear; echo "Wrong password!"
			fi
		  else echo "there is no password file.Create one plz."
			fi;;
	3)
		
		echo "Which is your best friend?"
		read maybebestfriend
		  realbestfriend=`cat /home/alex/Documents/PASS/recallquestion_PASS`
		if [ "$maybebestfriend" = "$realbestfriend" ]; then
			recall=`cat /home/alex/Documents/PASS/bringagain_PASS`
			echo "The password which you forgot is $recall"
		else 
			clear; echo "Wrong answer to the question which is your best friend.Try again."
		fi;;
		
	4)
		echo "Which is the current password?"
		read givenpassasexisted
			existpass=`cat /home/alex/Documents/PASS/password_PASS`
		         if [ "$existpass" = "$givenpassasexisted" ]; then
			 echo "Which is your best friend?"
			 read bestfriend
			 echo $bestfriend > /home/alex/Documents/PASS/recallquestion_PASS
		else 
			echo "Wrong password.Try again!"
			fi
		
	esac

i think it is pretty good! It has option to change your password, answer to the recall question in order to take it back and change the question to the recall question !
 

10 More Discussions You Might Find Interesting

1. Programming

getting username from a c program in unix

How to get the user name of the Operating system from a c program. eg:- -rw-r----- 1 gkuser srth1 292 Jul 27 19:28 u1.txt i need to get gkuser as the result? (3 Replies)
Discussion started by: Rajeshsu
3 Replies

2. Shell Programming and Scripting

username password in script

Can we write a script to telnet to a unix server from unix with the username and password hardcoded in the script?? something like ssh a@b -p password ??? (5 Replies)
Discussion started by: roshanjain2
5 Replies

3. Shell Programming and Scripting

Read Oracle Username password SID from single file and pass it to shell

Dear All I am trying to write one shell which will be running through Cron which contain one SQL query. But I want to draw/fetch the Username password and Instance name (required to loging to the database) from one single file to run that SQL query . Also this file contain details of multiple... (2 Replies)
Discussion started by: jhon
2 Replies

4. UNIX for Dummies Questions & Answers

How can i hide username/password

hi all, i run sqlplus command on unix(HP-UX) like "sqlplus username/password@serverA @deneme.sql" but when someone run "ps -ef | grep sqlplus", it can see my username and password :( How can i hide username and password. thanx. (1 Reply)
Discussion started by: temhem
1 Replies

5. UNIX for Advanced & Expert Users

Login through SFTP using username and password

Hi All, I want to login to a server through SFTP by giving username and password, in an automated script. I know that this can be done through public key authentication, but my requirement is to login ONLY through username and password. I am using GNU/Linux server. Please advise me !!!... (4 Replies)
Discussion started by: sparks
4 Replies

6. Shell Programming and Scripting

Asking username and password in the middle of the Shell/perl script

Can any body help me to find out the logic I have a script chkcomponent.pl Which give some output Like component1 userid: u1 component2 userid: u2 component3 userid: u1 . . #The no of components are different in different times run Now I want this chkcomponent.pl script... (1 Reply)
Discussion started by: pareshpatra
1 Replies

7. Shell Programming and Scripting

Username and password

Hi I am new to using unix and am struggling with a script i am writing. What i am trying to do is get a user to enter a username, check the original file i created with username and pin to see if their is a corresponding entry. Next ask the user to enter the pin and see if this matches... (5 Replies)
Discussion started by: somersetdan
5 Replies

8. UNIX for Dummies Questions & Answers

How do you reset username/password

Picked up a 3b2 running System V. Works fine, but it requires a username and password. Is the username "root" or "sysadm"? How do I find out and how to I reset it or bypass it? Thanks. (2 Replies)
Discussion started by: TanRuNomad
2 Replies

9. Programming

Getting username from an informix 4gl program in UNIX

How to get the user name of the Operating system from an Informix 4gl program. eg:- -rw-r----- 1 gkuser srth1 292 Jul 27 19:28 u1.txt i need to get gkuser as the result? (0 Replies)
Discussion started by: enriquegm82
0 Replies

10. Shell Programming and Scripting

Passing Username & password through shell script to java code

Hi, I have a shell script (script.sh) in which we are calling java code which asks for Username: Password: for authentication purpose currently we are passing the credential manually and run the script. but I am trying echo -e "user_id\npassword" | script.sh but its not... (1 Reply)
Discussion started by: rakeshtomar82
1 Replies
d_passwd(4)							   File Formats 						       d_passwd(4)

NAME
d_passwd - dial-up password file SYNOPSIS
/etc/d_passwd DESCRIPTION
A dial-up password is an additional password required of users who access the computer through a modem or dial-up port. The correct pass- word must be entered before the user is granted access to the computer. d_passwd is an ASCII file which contains a list of executable programs (typically shells) that require a dial-up password and the associ- ated encrypted passwords. When a user attempts to log in on any of the ports listed in the dialups file (see dialups(4)), the login program looks at the user's login entry stored in the passwd file (see passwd(4)), and compares the login shell field to the entries in d_passwd. These entries determine whether the user will be required to supply a dial-up password. Each entry in d_passwd is a single line of the form: login-shell:password: where login-shell The name of the login program that will require an additional dial-up password. password An encrypted password. Users accessing the computer through a dial-up port or modem using login-shell will be required to enter this password before gaining access to the computer. d_passwd should be owned by the root user and the root group. The file should have read and write permissions for the owner (root) only. If the user's login program in the passwd file is not found in d_passwd or if the login shell field in passwd is empty, the user must sup- ply the default password. The default password is the entry for /usr/bin/sh. If d_passwd has no entry for /usr/bin/sh, then those users whose login shell field in passwd is empty or does not match any entry in d_passwd will not be prompted for a dial-up password. Dial-up logins are disabled if d_passwd has only the following entry: /usr/bin/sh:*: EXAMPLES
Example 1: Sample d_passwd file. Here is a sample d_passwd file: /usr/lib/uucp/uucico:q.mJzTnu8icF0: /usr/bin/csh:6k/7KCFRPNVXg: /usr/bin/ksh:9df/FDf.4jkRt: /usr/bin/sh:41FuGVzGcDJlw: Generating An Encrypted Password The passwd (see passwd(1)) utility can be used to generate the encrypted password for each login program. passwd generates encrypted pass- words for users and places the password in the shadow (see shadow(4)) file. Passwords for the d_passwd file will need to be generated by first adding a temporary user id using useradd (see useradd(1M)), and then using passwd(1) to generate the desired password in the shadow file. Once the encrypted version of the password has been created, it can be copied to the d_passwd file. For example: 1. Type useradd tempuser and press Return. This creates a user named tempuser. 2. Type passwd tempuser and press Return. This creates an encrypted password for tempuser and places it in the shadow file. 3. Find the entry for tempuser in the shadow file and copy the encrypted password to the desired entry in the d_passwd file. 4. Type userdel tempuser and press Return to delete tempuser. These steps must be executed as the root user. FILES
/etc/d_passwd dial-up password file /etc/dialups list of dial-up ports requiring dial-up passwords /etc/passwd password file /etc/shadow shadow password file SEE ALSO
passwd(1), useradd(1M), dialups(4), passwd(4), shadow(4) WARNINGS
When creating a new dial-up password, be sure to remain logged in on at least one terminal while testing the new password. This ensures that there is an available terminal from which you can correct any mistakes that were made when the new password was added. SunOS 5.10 2 Sep 2004 d_passwd(4)
All times are GMT -4. The time now is 11:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy