Hey guys-
I'm trying to create a BASH script that will connect to a remote server, via SSH that requires a password, and then search a log file for the word error, store the output in a file, and then return the file to the local machine. I would like this process to be completely automated and run via cron. How would you go about supplying a password to SSH or scp? Is there a better way I should be doing this? I'd like to avoid the route of setting up public/private DSA/RSA keys, and would like to find a way to do this via scripting. I'd appreciate any input. Thanks in advance. So far, this is what I have.
#!/bin/bash
#Global Variables - Established in case variables are not passed to the script.
server="my_server" #The name of the server that we'll connect to.
local_server="host" #The name of the host machine.
uName="user" #The user name that we will use for this connection.
pass=`cat /root/LDAP.pwd` #A secure password file.
ssh -l $uName $server <<- EOF #I need a password here somehow
cd /var/log
grep error log.txt > myErrors.txt
scp myErrors.txt $uName@$local_server #I need a password here somehow
EOF