既然这件事已经发生了,我只想把相关的帖子排除在外:
拒绝许可(公开密钥);不是我的问题:
最接近我的人,也是我现在的位置,但不是为我工作的:
没有迹象表明,到底是什么导致顶部的答案被标记出来,但我对建议的故障排除脚本或手动无密码/ssh代理推送到github没有任何问题。
我有一个python文件,它可以写入日志,我希望它每分钟从raspberry pi自动推送到github。下面是剧本:
~/dir/script
export HOME=/home/uname
cd /home/uname/dir/
echo $HOME
pwd
whoami
python2 ./python-script.py
git commit -am "update"
git push当我手动运行它时,我得到以下输出:
$ ./script
/home/uname
/home/uname/dir
uname
done ### print from script
[master 0db9599] update
1 file changed, 1 insertion(+), 1 deletion(-)
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 306 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To uname@github.com:uname/repo.git
def0bed..0db9599 master -> master一切看起来都很棒!
下面是crontab行(通过crontab -e作为我的常规用户编辑):
*/1 * * * * /home/uname/dir/script以下是运行journalctl后的cron日志:
CROND[13791]: pam_unix(crond:session): session closed for user uname
crond[13862]: pam_unix(crond:session): session opened for user uname by (uid=0)
CROND[13863]: (uname) CMD (/home/uname/dir/script)
CROND[13862]: (uname) CMDOUT (/home/uname)
CROND[13862]: (uname) CMDOUT (/home/uname/dir
CROND[13862]: (uname) CMDOUT (uname)
CROND[13862]: (uname) CMDOUT (done)
CROND[13862]: (uname) CMDOUT ([master 4fd590d] update)
CROND[13862]: (uname) CMDOUT ( 1 file changed, 1 insertion(+), 1 deletion(-))
CROND[13862]: [50B blob data]
CROND[13862]: (uname) CMDOUT (fatal: Could not read from remote repository.)
CROND[13862]: (uname) CMDOUT ()
CROND[13862]: (uname) CMDOUT (Please make sure you have the correct access rights)
CROND[13862]: (uname) CMDOUT (and the repository exists.)
CROND[13862]: pam_unix(crond:session): session closed for user uname通过搜索一下以确保用户正确地设置了github,我尝试了在接受的答案here中显示的显式命令
git push ssh://uname@github.com/uname/repo.git我不是git专家,所以我认为这只是github上的一个例子,但它似乎也很好:
git push ssh://git@github.com/uname/repo.git我还尝试了来自~/.ssh/config的same answer above建议。即:
$ cat ~/.ssh/config
Host github-project1
User git
HostName github.com
IdentityFile ~/.ssh/id_rsa.pub然后:
git remote add github-project1 github-project1:uname/repo.git我尝试过的所有变体都得到了相同的结果;手动推送和脚本执行都很好,但是cron失败了。
我还能查到什么?
发布于 2016-03-15 23:33:51
通过cron + ssh-agent (没有密码)
Cron通常无法访问您的ssh-agent,因为您的shell中有环境变量$SSH_AUTH_SOCK,但它可能不在cron使用的环境变量中。
https://stackoverflow.com/questions/35998401
复制相似问题