Thursday | 21 NOV 2024
[ previous ]
[ next ]

Uploading Files

Title:
Date: 2023-07-15
Tags:  sysadmin

I wrote another routine to do ftp, this time for ftps. I think this would be a good time to list out all the various commands I'm using. This will be for uploading files. I'll do another post for the downloading.

scp is straightforward and can be done in a single line. Big fan of this.

sshpass -p 'password' scp /home/username/README.md username@127.0.0.1:/tmp/README.md

Raw ftp, insecure and the start of using docstrings to pass things in.

ftp -n <<EOF
open 127.0.0.1
user username password
put /home/username/README.md /tmp/README.md
quit
EOF

ftps is ftp but using TLS/SSL for security. This uses lftp which seems to work for ftp as well.

lftp <<EOF
open 127.0.0.1
user username password
set xfer:clobber on
put /home/username/README.md -o /tmp/README.md
quit
EOF

Lastly sftp is ftp but using ssh.

sshpass -p 'password' sftp -q username@127.0.0.1 <<EOF > /dev/null
put /home/username/README.md /tmp/README.md
quit
EOF

These are the basic commands to upload things to a server.

You can look at the various programs that I have written in BASIC to add in port numbers and for download examples.