Search code examples
sshcronssh-keys

Using .ssh keys in Crontab


One of my weekly scripts won't log into a LAN server now. I added another entry into ~/.ssh/config and the crontab entry isn't taking. I just tried fixing it by specifically adding that server parameters (it was represented by a wildcard entry when the crontab was working)

Load key "/Users/rich/.ssh/id_rsa": Permission denied
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

How can I fix this so the cron has access to that box? I tried copying over the key after my local change.

Here is my ~/.ssh/config file:

    Host *
        AddKeysToAgent yes
        UseKeychain yes

    Host uiop.local
        HostName uiop.local
        AddKeysToAgent yes
        UseKeychain yes
        IdentityFile ~/.ssh/id_rsa
        User rich

    Host qwer.local
        HostName qwer.local
        AddKeysToAgent yes
        UseKeychain yes
        IdentityFile ~/.ssh/id_rsa
        User rich

    Host github.com
        HostName github.com
        User Wonderful
        IdentityFile ~/.ssh/id_ed25519
        IdentitiesOnly yes

I also use rsync on a LAN box that isn't working now. With one key is present, it's assumed that key is the only one to use. But with the config file above, it still gets confused. I'm questioning if the keys are added to the agent.


Solution

  • Was permissions. Set to 600 on the whole .ssh directory.