Backup SH File HELP

General support questions
Post Reply
imanoobatthis
Posts: 1
Joined: 2018/07/17 08:09:12

Backup SH File HELP

Post by imanoobatthis » 2018/07/17 08:14:57

Hi everyone,

First time posting here but I have been on the forum a lot, just lurking.

I've been trying all night to get this stupid script working with a PPK file. I need to connect to an SFTP Server using a .PPK file with no password and I honestly think it is impossible.

An example of the script is below. It works perfectly when using a password but I have tried a ton of different ways to get it to work with a PPK. So the script below is a fully working one that accepts a password, I just need to be put in the right direction for it to use a PPK instead.

Code: Select all

#!/bin/sh
# FTP LOGIN
HOST='sftp://IPADDRESS'
USER='username'
PASSWORD='thisismypass'

# REMOTE DIRECTORY
REMOTE_DIR='/home/download'

#LOCAL DIRECTORY
LOCAL_DIR='/home/backup'

# RUNTIME!
echo
echo "Starting download $REMOTE_DIR from $HOST to $LOCAL_DIR"
date

lftp -u "$USER","$PASSWORD" $HOST <<EOF
# the next 3 lines put you in ftpes mode. Uncomment if you are having trouble connecting.
# set ftp:ssl-force true
# set ftp:ssl-protect-data true
# set ssl:verify-certificate no
# transfer starts now...
mirror --use-pget-n=10 $REMOTE_DIR $LOCAL_DIR;
exit
EOF
echo
echo "Transfer finished."
Let me know what you think. Thanks in advance all!

User avatar
TrevorH
Forum Moderator
Posts: 23653
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Backup SH File HELP

Post by TrevorH » 2018/07/17 13:11:05

PPK files are putty specific as far as I know. You would need to convert that to openssh format - putty has a utility for doing that or you can just load it into your favorite editor and hack it around in that until it's in the right format (needs you to know what that is of course).
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

hunter86_bg
Posts: 1372
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Backup SH File HELP

Post by hunter86_bg » 2018/07/17 14:01:27

Just open the file via putty gen and export the private key.Also in the top section , copy the public part and save it in a separate file .
Then you will have both public and private keys in a separate files.

Post Reply