0

I'm trying to transfer .bin files from my Raspberry Pi 2 to an Amazon S3 server using a bash script "connect_ftp_amazon" as follows:

#!/bin/bash

HOST='XX.XXX.XXX.XXX'
USER='my_user'
PASSWD='my_password'
DIR='/s3_folder'
LOCALPATH='/raspberrypi_folder'

ftp -inv $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
cd $DIR
lcd $LOCALPATH
mput *.bin
quit
exit;
EOF

However, when I try to execute it in the terminal window with

chmod a+x connect_ftp_amazon
sudo ./connect_ftp_amazon

I got

ftp: connect: Connection timed out
Not connected.
Not connected.
Not connected.
Local directory now /home/pi/raspberrypi_folder
Not connected.

I guess I'm passing my host and/or user parameters in the wrong format, as it works fine with a Linux server. Could somebody help me to identify what is wrong with my settings?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Do I have to install `aws cli` for this and follow the instructions explained [here](https://aws.amazon.com/es/getting-started/tutorials/backup-to-s3-cli/?nc1=h_ls) or just replace `ftp` with `aws s3` in my bash script above? – laizwithzed Jun 17 '18 at 17:32
  • Well, that depends on whether you already have `aws` installed or not. You probably don't. – Martin Prikryl Jun 17 '18 at 17:46
  • The technical error here is a duplicate of https://stackoverflow.com/questions/4937792/using-variables-inside-a-bash-heredoc – tripleee Jun 17 '18 at 18:09

1 Answers1

0

You cannot connect to Amazon S3 with FTP. You have to use S3 protocol.

Use aws s3 or s3cmd commands.

See Uploading files to S3 account from Linux command line.


Though you can mount S3 bucket to a (Linux) server and setup FTP/SFTP server there. See FTP/SFTP access to an Amazon S3 Bucket.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992