How to upload a file from the command line with FTP or SSH?

You can use scp to copy to a remote machine.

scp <file to upload> <username>@<hostname>:<destination path>

You're probably looking for SCP or similar.

#!/bin/bash

cd ./files-to-upload
scp * user@host:/path/to/upload/files/to

of 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"
done

but regular scp (like tangens suggestion) is the best.