Our Linux setup doesn't have keygen configured for passwordless authentication. Hence I am supposed to use only
EXPECT
for passwordless authentication in a shell script.
/usr/bin/expect> ${LOG_FILE}
set timeout 60
spawn sftp ${EWS_USER}@${EWS_HOST}:${TGT_DIR}
expect "*?assword:"
send "$password\r"
expect "sftp>"
send "put $local_dir/$line\r"
expect "sftp>"
send "bye\r"
expect EOF
EOF
filename=$(basename "$line")
# echo "File Name: $filename"
#Calculate the MD5Sum locally.
local_md5sum=$(md5sum "$line")
#echo "Local MD5Sum: ${local_md5sum}"
#Calculate the MD5sum in remote machine
remote_md5sum=$(ssh ${EWS_USER}@${EWS_HOST} "cd '$TGT_DIR' ; find -name '$filename' -exec md5sum {} \;" > ${LOG_NAME}
put ${LOCAL_DIR}/${line} ${TGT_DIR}/${line}
EOF
But any idea how to use EXPECT here in the scenario below to make the connection passwordless?
remote_md5sum=$(ssh ${EWS_USER}@${EWS_HOST} "cd '$TGT_DIR' ; find -name '$filename' -exec md5sum {} \;" < /dev/null)
Asked by sabarish jackson
(628 rep)
Oct 26, 2016, 01:56 PM
Last activity: May 7, 2025, 06:10 PM
Last activity: May 7, 2025, 06:10 PM