[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell Script on Debian



I presume everyone is aware of the risks associated with storing plaintext passwords in any file, including script files, and the ways of reducing (but not eliminating) said risks.....

For example (but by no means exhaustively) I wouldn't do chmod +x on the file, but would do chmod u+x. and also go-rwx, unless I had extremely compelling reasons otherwise.

Mike
Continuing an off-topic thread, I know, but......

ApOgEE wrote:
Owh, another thing... make sure you've installed 'expect'

# apt-get install expect

Good Luck!!


On Fri, Jun 27, 2008 at 4:50 PM, ApOgEE <jerungkun@gmail.com> wrote:
Hi,
There is another way... Here's my way to do it:
copy and paste this command:

$ cat > chpass << EOF
#!/bin/sh
# \\
exec expect -f "\$0" \${1+"\$@"}
set password [lindex \$argv 1]
spawn passwd [lindex \$argv 0]
sleep 1
expect "assword:"
send "\$password\r"
expect "assword:"
send "\$password\r"
expect eof
EOF


Then issue this command:
$ chmod +x chpass


to test it, just try this command:
$ ./chpass <username> <newpassword>

for example:
root@mydebian:root# /root/chpass root mynewrootpass
spawn passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@mydebian:root#

Good Luck!!



On Fri, Jun 27, 2008 at 12:45 PM, Phuong Phan Thi Bach
<ptbphuong@selab.hcmuns.edu.vn> wrote:
Hello,
The  "passwd" command expects to read the new password only from the
console, How to it read the new password only from a file.  I create a file
(Ex: test file )

test file
123456
123456
After, I use: "passwd < test" (shell on Debian is sh)
But it always error: "Enter new UNIX password: Retype new UNIX password:
Sorry, passwords do not match"
Please, could you help me.
Best regards,
Phuong




Reply to: