How do I do secure transfers?
I need to grab some CSV files from a remote location.
I will probably either get HTTP or SSH access. If I'm only granted HTTP access, what would be the most secure way to grab the file? I figure I can use wget using HTTPS. But what if I only get SSH access? I could use 'scp' but how do I get around the password prompt because this will be cronjob? Also, how can I send an email to more than one user via command line once the process of downloading these files are over? Thanks. |
What language you are using?
In any case I think Curl will be helpful. |
Hi Koobi
You can use keys in order to avoid scp asking password. The procedure in two words is to create a public and private key and copy the public key to the remote machine in the ~/.ssh directory. Now, about how you can send an email with multiple recipients, that depends what MTA is available on your machine. Just check the man pages or look it up. |
i would prefere getting ssh or https access rather than http if security was my concern
for scp you can have public key logins (see man page for ssh/scp command line option -i) also perhaps look at ssh-agent |
Here's an example of sending mail in bash. You just need to put a loop around it and feed in a list of email addresses eg from a file
usr1@somewhere usr2@somewhereelse etc http://theos.in/shell-scripting/send-mail-bash-script/ |
Quote:
I read up a bit about SCP and the identity file, it seems as though this will create two key files and one has to be placed in the remote server? The thing is, I can only read from the remote server, I don't have the authority to write anything to it. It looks as though HTTPS is my next safest bet, right? One more thing, assuming I do go with SCP, what if the file I'm attempting to access does not exist one day, can I get some soft of signal that will indicate this so that I can halt the rest of the processes that depend on the existence of this file? Quote:
I googled a bit and found that the following ways will also work to send emails: Code:
mail -s "My Subject" user@example.org < /path/to/message/body Thanks. |
In re your last, make 'user' a bash var and assign to it in a loop, somehting like
Code:
for user in 'a b c d e' |
Quote:
Thanks. But this brings me to another question. I know the following works this way: Code:
do_something () { But what if I wanted the second variable to be looped, can I make it an array? Thanks and sorry for the silly questions :) I've worked with PHP all my life, rarely worked with the shell. |
You really ned to read those links I gave you, it'll be quicker than posting qns (although come back if you really get stuck).
There are many ways of generating/using lists, but explicit arrays are explained here: http://www.tldp.org/LDP/abs/html/arrays.html |
Quote:
Thanks. |
I have another problem that I'm not sure how to solve because I don't know what to look for:
Code:
file_exists () { I want to send an email either with an existing template file as the body text or using the input as the body text, depending on how I input my parameters. But when I run this command, it tells me there are too many parameters...I'm guessing this is because it tries to stat the $3 argument which won't be possible if it's a string input with spaces in it. How can I work around this? At least tell me what to look for. Thanks. |
All times are GMT -5. The time now is 07:17 AM. |