Home » Questions » Computers [ Ask a new question ]

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

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

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?

Asked by: Guest | Views: 328
Total answers/comments: 4
Guest [Entry]

"You can use scp to copy to a remote machine.

scp <file to upload> <username>@<hostname>:<destination path>"
Guest [Entry]

"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."
Guest [Entry]

curl is a good program that handles several protocols.
Guest [Entry]

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.