crontab定时运行git命令 更新代码库
Q: http://stackoverflow.com/questions/7994663/git-push-via-cron
I presume it hasn't to do with finding or reading my ~/.ssh/id_rsa, as I can cat the file from cron alright. UID and EUID are set fine in the cron job. - Any ideas?
UPDATE
I got it working when supplying the environment key SSH_AUTH_SOCK to my cron job, but I'm concerned that this is only valid as long as I'm logged in. I'm looking for a solution that works independent of interactive logins.
A:
As explained here,it can be due to the lack of knowledge from the cron session shell of the ssh agent.
If that is the case (ie if you are using private ssh keys with a passphrase), keychain is the usual solution (as mentioned here).
More details in this example: "Passwordless connections via OpenSSH using public key authentication, keychain and AgentForward".
Very brief synopsis
1. Generate private/public key pair (id_dsa and id_dsa.pub).
Save private key in ~/.ssh/id_dsa on trusted hosts you will ssh from.
Append public key to ~/.ssh/authorized_keys on hosts you will ssh to.
Do not use ~/.ssh/authorized_keys2. If you see that file, remove it
and upgrade to a recent version of SSH.
2. Set ForwardAgent yes in ssh_config on all hosts you ssh
from. Set PubkeyAuthentication yes in sshd_config on all
hosts you ssh to. Maybe set StrictModes no in sshd_config.
3. Install keychain then configure by adding the following lines
to your $HOME/.bash_profile:
/usr/local/bin/keychain $HOME/.ssh/id_dsa
source $HOME/.keychain/${HOSTNAME}-sh
4. For crontab scripts that use ssh, add the following line in
order to avoid having to manually enter a passphrase:
source $HOME/.keychain/${HOSTNAME}-sh
5. ssh from host to host without needing to enter passwords. Where
you can ssh, you can also scp, sftp, etc., all securely but without
having to enter your passwords on the various hosts you use.
crontab定时运行git命令 更新代码库的更多相关文章
- 换个视角来看git命令与代码库发生网络交互报错事件
git的一系列命令中像 clone.pull.push等与代码库发生网络交互时,可能报下面的错误信息 fatal: remote error: CAPTCHA required Your Stash ...
- 15分钟学会使用Git和远程代码库
git是个了不起但却复杂的源代码管理系统.它能支持复杂的任务,却因此经常被认为太过复杂而不适用于简单的日常工作.让我们诚实一记吧:Git是复杂的,我们不要装作它不是.但我仍然会试图教会你用(我的)基本 ...
- 使用Git和远程代码库
git是个了不起但却复杂的源代码管理系统.它能支持复杂的任务,却因此经常被认为太过复杂而不适用于简单的日常工作.让我们诚实一记吧:Git是复杂的,我们不要装作它不是.但我仍然会试图教会你用(我的)基本 ...
- 【git】15分钟学会使用Git和远程代码库
Git是个了不起但却复杂的源代码管理系统.它能支持复杂的任务,却因此经常被认为太过复杂而不适用于简单的日常工作.让我们诚实一记吧:Git是复杂的,我们不要装作它不是.但我仍然会试图教会你用(我的)基本 ...
- 15 分钟学会使用 Git 和远程代码库
Git是个了不起但却复杂的源代码管理系统.它能支持复杂的任务,却因此经常被认为太过复杂而不适用于简单的日常工作.让我们诚实一记吧:Git是复杂的,我们不要装作它不是.但我仍然会试图教会你用(我的)基本 ...
- 基于git命令的代码统计方法
基于git命令的代码统计方法 没什么好说的,基于git log命令,使用前提是安装了git ...... .统计所有人代码量 统计所有人代码增删量,拷贝如下命令,直接在git bash等终端,git项 ...
- Linux-Centos 用crontab定时运行python脚本详细步骤
服务器总是要定时运行某个程序,而我在解决这个问题的时候遇到很多困难, 特此记录下来. 1.编辑crontab配置 crontab -e 服务器一般会安装好crontab,若没有安装请按命令安装 yum ...
- crontab 不能执行git命令问题备忘
这问题够隐蔽,折腾了近两个小时. 命令 git checkout tagname 手工执行都正常 但在crontab运行时发现分支一直切不过去. 后来告诉是crontab默认的 path 设置和系统 ...
- 00008 - crontab定时执行任务命令详解
linux 系统则是由 cron (crond) 这个系统服务来控制的.Linux 系统上面原本就有非常多的计划性工作,因此这个系统服务是默认启动的.另 外, 由于使用者自己也可以设置计划任务,所以, ...
随机推荐
- sicily 1010. 单词数值
本题主要是Hash思想的应用 课程上机练习题 Contest ends in 8 months 27 days
- ZigBee HA示例程序分析
ZigBee协议栈中自带的HomeAutomation例程,虽然也是操作灯泡,但是,是通过ZCL来统一处理的,符合HA profile规范,互连互操作性较好.下面就简要分析以下ZCL的使用. 在任务数 ...
- Android BroadcasetReceiver
ci@clinux:~/mp_mtk$ adb -s QGAEFYAAOFN7PNOB logcat PhoneReceiver:e *:S --------- beginning of system ...
- net.sf.json.JSONException: java.lang.NoSuchMethodException
在尝试将json对象转换为list时候出现了如下错误 Exception in thread "main" net.sf.json.JSONException: java.lang ...
- curl 报错记录,mark
今天在做接口开发的时候,使用curl post ,请求返回数据为 null ,很纳闷,然后使用 curl_errno 打印出来的错误代码为 28 ,curl_error($ch) 打印出来的是Oper ...
- JS遇到的问题解决
1.input 里使用onclick事件,整整花了1个半小时,onclick里面直接用Location.href不需要加<script></script> <?php / ...
- Android API Level与sdk版本对照表
API等级1: Android 1.0 API等级2: Android 1.1 Petit Four 花式小蛋糕 API等级3: Android 1.5 Cupcake 纸杯蛋糕 API等级4: An ...
- C string 函数大全
PS:本文包含了大部分strings函数的说明,并附带举例说明.本来想自己整理一下的,发现已经有前辈整理过了,就转了过来.修改了原文一些源码的问题,主要是用char *字义字符串的问题,导致程序运行时 ...
- 系统中使用frameset和Iframe刷新页面session失效
问题:Asp.net中每次刷新页面,session中保存的只就丢失 原因: 1.有些杀毒软件会去扫描web.config文件 2.程序内部有让session丢失的代码,或服务器内存不足 3.程序有框架 ...
- WPF中的DataTemplate
<Window x:Class="DateTemplate应用.MainWindow" xmlns="http://schemas.microsoft.com/wi ...