Question about reading input from terminal

stevovo

Expert Member
Joined
Apr 24, 2008
Messages
1,496
Reaction score
2
Location
Pretoria
Ok I tried googling this but it's just so specific that I cant find anything :p

First, the background:

I read somewhere that typing stuff in the terminal (running everyday commands) gets stored somewhere. In other words, I have a truecrypt partition and I dont want to type the password in the terminal (ie. sudo truecrypt --mount /dev/sdb --password *mypassword*) cos it will be easily recovered, so I first run truecrypt and type it in there - all is fine.

Now the question:

I want to have a few truecrypt drives, but it is darn annoying having to keep typing in a long password each time. Is it possible to have for eg. 3 truecrypt drives with the same password, and then using a SCRIPT, read in the password once from the terminal into a variable or wherever and then execute the appropriate command once for each drive without compromising my password?
 
I think you're looking for expect. I haven't used it myself, but it seems like it'd take a bit of time to set it up...which might be offset by the number of times you'll use it in the future.

Anyway, here's a bash script that prompts you for your password (so it's not stored in the command history).

Code:
#!/bin/bash
read password
truecrypt --mount /dev/sdb --password $password #first drive
truecrypt --mount /dev/sdc --password $password #second drive etc.
 
Last edited:
there is a history of commands typed into the terminal and certainly nothing showing the password you typed in when prompted.
 
there is a history of commands typed into the terminal and certainly nothing showing the password you typed in when prompted.

By prompt do you mean using the 'read' command in a script?

Just to clarify, so if I use for eg. the following script there wont be any traces of my password:

Code:
#!/bin/sh
echo -n "Enter password: "
read pass
truecrypt --mount /dev/sdb --password $pass

EDIT: oops, I think I missed your post there concentricpuddle. Thanks for the help :D
 
Last edited:
What milomak is trying to say is that your passwords are never stored anywhere on your system by some log file.

Your command history will be found in /root/.bash_history or ~/.bash_history .

If you view that file you will notice that no passwords are stored.

You can tinker with this file to allow it to hold history for a couple of days, indefinite or only a certain number of commands (measured by size of file, etc.)
 
Thanks, I actually never knew where those commands were stored, now I know! :D

BTW this is off topic but does anyone know where the history is kept for files that are "double-clicked" like a video file for eg.?
 
That will be window manager specific, KDE stores it differently from Gnome, what DE/WM are you using?
 
Top
Sign up to the MyBroadband newsletter
X