I am writing some shell scripts to automatically download software packages off my server and set them up on customer servers. At some point within the script, the download command is wget http://example.com/file/secure_download.tar.gz - I will rather not have this sensitive file available on a public server since anyone can scan and download the files too. I can however, require authentication to those directories, but how do I pass the access credentials along with the wget command? Or Is there a better way to accomplish?
From wget manual:
Specify the username user and password password for both FTP and HTTP file retrieval. These parameters can be overridden using the ‘--ftp-user’ and ‘--ftp-password’ options for FTP connections and the ‘--http-user’ and ‘--http-password’ options for HTTP connections.
So what you are looking for is:
$ wget --user=n3rve --password='mylittlepony' http://example.com/file/secure_download.tar.gz
If possible I would suggest setting up an SFTP server where instead you can create and share SSH-keys between you and your customer servers and they securely connect to your SFTP server and pull the files they require.
This is a far more secure method than using
wget on a web server. The entire setup would require you asking for your customers to provide you with their public key, you adding their
id_rsa.pub to their
.ssh/authorized_keys file and they would connect by:
$ sftp firstname.lastname@example.org [OR] $ sftp email@example.com
*note, no password is required because you created a trusted network with your ssh-key pair.