2

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?

1

From wget manual:

‘--user=user’

‘--password=password’

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 n3rve@domain.name 
[OR]
$ sftp n3rve@ip.address

*note, no password is required because you created a trusted network with your ssh-key pair.

3
  • sftp or scp or rsync -- all use ssh keys – glenn jackman Jan 29 '15 at 4:07
  • Thank you very much for your answer @DevNull. It seems I'd settle with wget seeing as asking every user for their public SSH key will require additional effort on my part. I want this completely automated. – Ralph Jan 29 '15 at 10:17
  • the --password method is an insecure way to provide the password to wget. The parameters given to a process are easily visible through utilities like top and ps – Alexander Oct 5 '15 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.