我已經看過類似的問題,但還沒有找到答案。回購不會克隆,「權限被拒絕」,使用git模塊
我可以通過SSH連接到服務器(Ubuntu 16.04)並手動克隆我的git倉庫。這讓我相信它不是一個SSHForwardAgent問題。
的錯誤是非常典型:
"Cloning into bare repository '/home/deploy/apps/MYPROJECT/production/cached-copy'...",
"Permission denied (publickey).",
"fatal: Could not read from remote repository.",
ansible.cnf:
[ssh_connection]
ssh_args = -o ForwardAgent=yes
的作用是這樣的:
- name: Update the bare Git repository
become_user: "{{ deploy_user }}"
git:
repo: "[email protected]:MYUSER/MYPROJECT.git"
dest: "{{ deploy_to }}/cached-copy"
version: "{{ branch }}"
bare: yes
update: yes
accept_hostkey: yes
ssh_opts: "-o StrictHostKeyChecking=no -o ForwardAgent=yes"
從Ansible詳細輸出是:
"changed": false,
"cmd": "/usr/bin/git clone --bare '' /home/deploy/apps/MYPROJECT/production/cached-copy",
"failed": true,
"invocation": {
"module_args": {
"accept_hostkey": true,
"bare": true,
"clone": true,
"depth": null,
"dest": "/home/deploy/apps/MYPROJECT/production/cached-copy",
"executable": null,
"force": false,
"key_file": null,
"recursive": true,
"reference": null,
"refspec": null,
"remote": "origin",
"repo": "[email protected]:MYUSER/MYPROJECT.git",
"ssh_opts": "-o StrictHostKeyChecking=no -o ForwardAgent=yes",
"track_submodules": false,
"umask": null,
"update": true,
"verify_commit": false,
"version": "master"
MYUSER和MYPROJECT的使用是收回此類信息。
有一點看起來可疑是cmd
它不包含回購網址,這是正常的嗎?
如果我將-o ForwardAgent=yes
更改爲-A
,則會得到不同的錯誤:Timeout (12s) waiting for privilege escalation prompt
。
另外我知道AgentForward正在工作,因爲如果我ssh進入服務器並做ssh -T [email protected]
我得到預期的「您已成功驗證,但GitHub不提供shell訪問。」。
請注意我不想在服務器上安裝私鑰。
更新:下面是詳細輸出的要點:https://gist.github.com/krisleech/8bfbf817c237258a672b3b3393fea8dd
在另一方面,這似乎很好地工作:
- name: "Test github"
command: ssh -T [email protected]
什麼是'become_user:「{{deploy_user}}」'for?它與你的遠程用戶有什麼不同(你使用ssh連接)?在這種情況下,您的ssh代理套接字可能在_becoming_不同的用戶之後無法訪問。 –
我'admin'和'deploy'用戶,管理員用戶可以sudo,最'deploy'用戶不能。我試圖刪除這條線,但沒有效果。我可以以任何用戶身份ssh並克隆回購。 – Kris
你調用與'become'選項任務(後'ssh命令的輸出-vvv'這個任務執行)?當你登錄的任一用戶SSH代理的作品,但在登錄後停止工作,當你'sudo'。 –