ssh代理和crontab

编程入门 行业动态 更新时间:2024-10-15 22:29:38
本文介绍了ssh代理和crontab - 有没有一个很好的方法来让这些满足?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写了一个简单的脚本,它向我们的开发人员发送svn活动日志。到现在为止,我在svn存储库的同一台机器上运行它,所以我不必担心身份验证,我只能使用svn的文件:/// address style。

I wrote a simple script which mails out svn activity logs nightly to our developers. Until now, I've run it on the same machine as the svn repository, so I didn't have to worry about authentication, I could just use svn's file:/// address style.

现在我在家用计算机上运行脚本,访问远程存储库,因此我必须更改为svn + ssh://路径。在正常情况下,我不需要输入密码来访问svn存储库。

Now I'm running the script on a home computer, accessing a remote repository, so I had to change to svn+ssh:// paths. With ssh-key nicely set up, I don't ever have to enter passwords for accessing the svn repository under normal circumstances.

但是,crontab没有访问我的ssh-keys / ssh-agent。我已经在网络上的几个地方读过这个问题,它也被暗示到这里,没有解决:

However, crontab did not have access to my ssh-keys / ssh-agent. I've read about this problem a few places on the web, and it's also alluded to here, without resolution:

为什么ssh从crontab失败,但是从命令行执行时成功?

我的解决方案是将它添加到脚本的顶部:

My solution was to add this to the top of the script:

### TOTAL HACK TO MAKE SSH-KEYS WORK ### eval `ssh-agent -s`

这似乎在MacOSX 10.6下工作。

This seems to work under MacOSX 10.6.

我的问题是,这是多么可怕,有更好的方法吗?

My question is, how terrible is this, and is there a better way?

推荐答案

当您运行ssh-agent -s时,它会启动一个后台进程,您需要稍后再杀。所以,最低限度是改变你的黑客到像:

When you run ssh-agent -s, it launches a background process that you'll need to kill later. So, the minimum is to change your hack to something like:

eval `ssh-agent -s` svn stuff kill $SSH_AGENT_PID

但是,我不明白这个黑客是如何工作的。只运行代理而不运行ssh-add将不会加载任何密钥。也许MacOS的ssh代理的行为不同于手册页表示。

However, I don't understand how this hack is working. Simply running an agent without also running ssh-add will not load any keys. Perhaps MacOS' ssh-agent is behaving differently than its manual page says it does.

更多推荐

ssh代理和crontab

本文发布于:2023-11-23 18:52:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622512.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ssh   crontab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!