我写了一个简单的脚本,它向我们的开发人员发送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
发布评论