LDP/LDP/guide/docbook/abs-guide/encryptedpw.sh

47 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2001-09-04 13:27:31 +00:00
# Example "ex72.sh" modified to use encrypted password.
2003-11-03 16:25:16 +00:00
# Note that this is still rather insecure,
2001-10-15 14:21:41 +00:00
#+ since the decrypted password is sent in the clear.
2003-11-03 16:25:16 +00:00
# Use something like "ssh" if this is a concern.
2001-10-15 14:21:41 +00:00
2009-09-29 15:08:03 +00:00
E_BADARGS=85
2001-07-10 14:25:50 +00:00
if [ -z "$1" ]
then
echo "Usage: `basename $0` filename"
2001-09-04 13:27:31 +00:00
exit $E_BADARGS
2001-07-10 14:25:50 +00:00
fi
2001-09-04 13:27:31 +00:00
Username=bozo # Change to suit.
2001-10-15 14:21:41 +00:00
pword=/home/bozo/secret/password_encrypted.file
# File containing encrypted password.
2001-07-10 14:25:50 +00:00
2004-11-15 13:35:56 +00:00
Filename=`basename $1` # Strips pathname out of file name.
2001-07-10 14:25:50 +00:00
Server="XXX"
Directory="YYY" # Change above to actual server name & directory.
2001-07-10 14:25:50 +00:00
2001-10-15 14:21:41 +00:00
Password=`cruft <$pword` # Decrypt password.
# Uses the author's own "cruft" file encryption package,
#+ based on the classic "onetime pad" algorithm,
#+ and obtainable from:
2003-08-25 14:48:48 +00:00
#+ Primary-site: ftp://ibiblio.org/pub/Linux/utils/file
2001-10-15 14:21:41 +00:00
#+ cruft-0.2.tar.gz [16k]
2001-07-10 14:25:50 +00:00
ftp -n $Server <<End-Of-Session
user $Username $Password
binary
bell
cd $Directory
put $Filename
bye
End-Of-Session
2001-09-04 13:27:31 +00:00
# -n option to "ftp" disables auto-logon.
2004-11-15 13:35:56 +00:00
# Note that "bell" rings 'bell' after each file transfer.
2001-07-10 14:25:50 +00:00
exit 0