From 0f67e734ed058bbc64fcc2ca972fa4fb0db37c10 Mon Sep 17 00:00:00 2001 From: agp8x Date: Sun, 29 May 2016 23:55:03 +0200 Subject: [PATCH] added sftp with password to copy files --- getssl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/getssl b/getssl index c59c6fe..b9f4be8 100755 --- a/getssl +++ b/getssl @@ -400,6 +400,23 @@ copy_file_to_location() { # copies a file, using scp if required. lcd $fromdir put $fromfile _EOF + elif [[ "${to:0:5}" == "sftp:" ]] ; then + debug "using sftp to copy the file from $from" + ftpuser=$(echo "$to"| awk -F: '{print $2}') + ftppass=$(echo "$to"| awk -F: '{print $3}') + ftphost=$(echo "$to"| awk -F: '{print $4}') + ftplocn=$(echo "$to"| awk -F: '{print $5}') + ftpdirn=$(dirname "$ftplocn") + ftpfile=$(basename "$ftplocn") + fromdir=$(dirname "$from") + fromfile=$(basename "$from") + debug "sftp user=$ftpuser - pass=$ftppass - host=$ftphost dir=$ftpdirn file=$ftpfile" + debug "from dir=$fromdir file=$fromfile" + sshpass -p $ftppass sftp $ftpuser@$ftphost <<- _EOF + cd $ftpdirn + lcd $fromdir + put $fromfile + _EOF else mkdir -p "$(dirname "$to")" if [ $? -gt 0 ]; then