在 Crontab 中使用 .ssh 密钥

Using .ssh keys in Crontab

我的每周脚本之一现在无法登录 LAN server。我在 ~/.ssh/config 中添加了另一个条目,但 crontab 条目没有被占用。我只是尝试通过专门添加 server 参数来修复它(当 crontab 工作时它由通配符条目表示)

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

我该如何解决这个问题,以便 cron 可以访问该框?我尝试在本地更改后复制密钥。

这是我的 ~/.ssh/config 文件:

    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

我还在 LAN 盒子上使用了 rsync,但现在无法使用。如果存在一把钥匙,则假定该钥匙是唯一可以使用的。但是对于上面的 config 文件,它仍然会感到困惑。想问问有没有给agent加key

是权限。在整个 .ssh 目录上设置为 600