I want to write a shell script and put it in a cron. This shell script will copy one particular directory from my server to another server everyday once. So, I don't want it to prompt for passwords. Is there something that I can add in my script so that it wont ask for passwords everyday?
Asked
Active
Viewed 462 times
0
-
You will want to see [**How to setup the passwords-less authentication between two different accounts**](http://stackoverflow.com/questions/36171227/how-to-setup-the-passwords-less-authentication-between-two-different-accounts/36172337?s=1|0.4401#36172337) and then use `rsync` within your `cron` script to backup files from host1 to host2. – David C. Rankin Aug 08 '16 at 06:30
3 Answers
1
You need to have a password less SSH Login in your Unix Boxes
Below link describe how to set password less SSH login
http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
you can use FTP or NDM to transfer the Files
In this way you can achieve your requirement.

Bhavesh
- 909
- 2
- 23
- 38
-
1Can I use rsync? because I need this script to run everyday, so instead of copying again and again, It will just update. If this is possible then explain how?? – darecoder Aug 04 '16 at 10:36
-
I have never used rsync in my case we get fresh new files daily so we copy daily – Bhavesh Aug 04 '16 at 11:39
-
1Using this script I am able to achieve what I mentioned earlier : com="sshpass -p Password0 scp arul@172.25.184.93:/home/arul/test.sh ." eval $com – darecoder Aug 08 '16 at 05:15
-
1
Using the below script, I am able to achieve what I mentioned :
#!/bin/bash com="sshpass -p Password0 scp arul@172.25.184.93:/home/arul/test.sh ." eval $com

darecoder
- 1,478
- 2
- 14
- 29
0
You can use RSA key option also for this. Using RSA key you can authorized your second server in first server. This is one time operation.
ssh-copy-id -i ~/.ssh/id_rsa.pub [Your 2nd server IP]
Example:-
[root@vasmon home]# ssh-copy-id -i ~/.ssh/id_rsa.pub xxx.xxx.xxx.xxx
root@xxx.xxx.xxx.xxx's password:
Now try logging into the machine, with "ssh 'xxx.xxx.xxx.xxx'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@vasmon home]#

UUU
- 153
- 1
- 7