Reading password from /dev/tty


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Reading password from /dev/tty
# 1  
Old 01-30-2012
Reading password from /dev/tty

hi,
From the below script:
Code:
##########################################pwd_auth.sh########################################################################################
#Author: Pandeeswaran Bhoopathy
#Written on:26th Jan 2012 2:00PM
#This script describes the feature of stty and illustrates the authentication mechanism
#############################################################################################################################################
#!/usr/bin/bash
printf "Enter the password:\n"
stty -echo 
read password </dev/tty
printf "Enter the passwrd again:\n"
read passwrd1</dev/tty
if [ $password = $passwrd1 ]
then
echo "Both the passwords match\n"
else
printf "Passwords do not match\n"
fi
stty echo

is it possible to print the password intermediately in the above script?i.e:is it possible to read the password from /dev/tty?
Similarly, while using
Code:
read -s

,can we retrieve the typed text from where its getting stored . i guess it's /proc/core.but i am unable to retrieve from there.
Please help me.

Thanks
# 2  
Old 01-30-2012
Why do you want to?

How to do so can vary from system to system, and even the manner the password is stored in can vary. You need root access to do so anyway, which makes it fairly useless unless you've got control of the machine anyway. Extracting a password from memory is like trying to read a hard drive with an electron microscope; might be technically possible, but an exercise in frustration, and used only in desperate (or fraudulent) circumstances.
# 3  
Old 01-30-2012
Yes/i just want to try in my system. Actuall y i have created that script for understanding the concept of stty. so out of curious,i am asking how to read the text from /dev/tty.
Thanks
# 4  
Old 01-30-2012
You can see how to read text from /dev/tty:

Code:
read < /dev/tty

If you want to rip variable values from memory, I can't help you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python: Redirecting to tty and reading from tty

In bash, you can do something like this: #!/bin/bash echo -n "What is your name? " > /dev/tty read thename < /dev/tty How can I do the same in python? I have a python script that has the following content: #!/usr/bin/python2.7 import getpass import sys import telnetlib import... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Simply question about capturing output to /dev/tty

Suppose another person wrote the following one-line shell script: echo $RANDOM > /dev/tty QUESTION #1: How can the random number, which is output to the terminal by this script, be captured in a variable? QUESTION #2: How can this be done in a cron job? Specific code, whether in ksh or... (1 Reply)
Discussion started by: Paul R
1 Replies

3. Shell Programming and Scripting

Forcing a tty session but getting a password prompt?

I have a master host I want to use to issue some start/stop of LDAP services. I changed the client hosts /etc/sudoers to have Defaults:infra !requiretty The master host kicks off the jobs using the infra account doing a ssh session to the infra account on the clients. #!/bin/ksh ps -fu... (5 Replies)
Discussion started by: J-Man
5 Replies

4. UNIX for Dummies Questions & Answers

/dev/tty find last modified time

what can I use to find the last modified time of a /dev/tty ? (4 Replies)
Discussion started by: l flipboi l
4 Replies

5. Programming

Create a pipe to /dev/tty

Hello everybody: I have a child process which reads a password from /dev/tty, as far as I know file descriptors for the child process can be seen by using lsof, so I want to connect to such device in order to send the password through a pipe, how could I do that? (2 Replies)
Discussion started by: edgarvm
2 Replies

6. UNIX for Dummies Questions & Answers

read from terminal/keyboard > /dev/tty

Hi, I need to provide more than one character to "> /dev/tty" through terminal/keyboard input, I have this: ok=false while do echo " Enter r1 to reformat " > /dev/tty read choice case $choice in ) echo " bla bla bla " ;; done However, in this way,... (3 Replies)
Discussion started by: Gery
3 Replies

7. Programming

What happens on opening /dev/tty failure?

Since the existence of /dev/tty is not guaranteed, what happens when an attempt is made to open /dev/tty and there's no controlling terminal? Will it fail, or open /dev/null instead? Or do something else? So is checking for NULL in the code below a safe way of checking whether opening... (2 Replies)
Discussion started by: gencon
2 Replies

8. Programming

sniff /dev/tty

hello all, Being root, I would like to log user activity (also multiple root activity), i don't really like history file based logging, lets assume that users have access to their .profile. I would like to write a monitoring daemon in C that would capture /dev/ttys, so I need to do a... (0 Replies)
Discussion started by: wayward
0 Replies

9. Solaris

What is /dev/tty /dev/null and /dev/console

Hi, Anyone can help My solaris 8 system has the following /dev/null , /dev/tty and /dev/console All permission are lrwxrwxrwx Can this be change to a non-world write ?? any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies

10. UNIX for Dummies Questions & Answers

Cannot open "/dev/tty"

Hi, When it proccesing the backup with cpio report this message: Cannot open "/dev/tty" and cancel de backup. Cuando se procesa la tarea del backup reporta el error: Cannot open "/dev/tty" y cancela el backup y no termina correctamente, a que se devera esta advertencia. Gracias. Thacks.... (3 Replies)
Discussion started by: cmr88
3 Replies
Login or Register to Ask a Question