I have never done this before and I am creating a bash shell script to do this for me. I will also be connecting via ssh to do some things (which I already know how to do). So maybe there is a way to upload files via ssh so I can do it all in one connection?
How can I do this?
#!/bin/sh
cd ./files-to-upload
#upload the files 1 7 Answers
You can use scp to copy to a remote machine.
scp <file to upload> <username>@<hostname>:<destination path> 6 You're probably looking for SCP or similar.
#!/bin/bash
cd ./files-to-upload
scp * user@host:/path/to/upload/files/toof course this must be tweaked to your liking.Replace user@host with your real information. You will be prompted for a password to upload.
If you really must use ssh (instead of scp) you can do:
for filename in *; do cat $filename | ssh user@host "cd /path/to/upload/files/to; cat - > $filename"
donebut regular scp (like tangens suggestion) is the best.
1For ec2 instance, you have to pass the .pem file also,
$scp -i ~/Desktop/amazon.pem ~/Desktop/file.zip :~/data/ scp is the better answer since it would be encrypted over SSH.
However, if you do want to do it over standard ftp, look at ncftpput. It's designed specificly to upload a file:
NAME ncftpput - Internet file transfer program for scripts
SYNOPSIS ncftpput [options] remote-host remote-directory local-files...
curl is a good program that handles several protocols.
When you use the scp (secure copy) command it connects to the client and if you don’t already have a fingerprint saved for the host device it will ask you for the host password otherwise it should auto connect to the host I believe.