ssh through cron scripts.

Discussion in 'Mac Apps and Mac App Store' started by knome, Mar 9, 2009.

  1. knome macrumors 6502

    knome

    Joined:
    Sep 7, 2006
    #1
    I'm having issues setting up cron scripts that log into a server automatically via ssh.

    I created the automatic ssh login using this:
    http://www.ccp4.ac.uk/peter/programming/automatic_ssh_login.html

    i followed this how to in order to set the the cron job:
    http://www.tech-geeks.org/contrib/mdrone/cron&crontab-howto.htm

    I tested the scrip manually but it still requires me to enter the password for the ssh login. But if i manually type it in the console it logs me into the server instantly without a password.

    So how do you get the auto ssh login to work inside of scripts?

    How do i check to see if my cron job has been added?

    here is the scrip i am trying to run

    Code:
    #!/bin/bash
    
    rsync -v -r -z -u --exclude '.DS_Store' user@myserver:/media/extra/backups/projects/ /Users/myusername/Documents/Projects/
    
    
    
    Here is the code that i injected into the crontab

    0 * * * * /etc/periodic/hourly/*
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
  3. knome thread starter macrumors 6502

    knome

    Joined:
    Sep 7, 2006
    #3
    Thats what has me confused. I did this about 9 months ago with a different computer and the same server for backups and i don't have a line like that in the cron file and it works just fine. I have absolutely no idea what i did.
     
  4. knome thread starter macrumors 6502

    knome

    Joined:
    Sep 7, 2006
    #4
    Well now i have to start from scratch. I was messing with it and now not only is my old one not working but i can't get any type of auto login to work now. :mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad:
     
  5. Beerfloat macrumors regular

    Beerfloat

    Joined:
    Feb 21, 2009
    #5
    Use:
    crontab -l [optionally -u username]

    Keep in mind that every user has their own crontab file, and their own .ssh/authorized_keys file

    It sounds like you may not be running your script with the same user that is allowed in the remote authorized_keys
     

Share This Page