SSH Agent Forwarding with Ansible

前端 未结 4 559
野性不改
野性不改 2020-12-02 06:12

I’m using Ansible 1.5.3 and Git with ssh agent forwarding (https://help.github.com/articles/using-ssh-agent-forwarding). I can log into the server that I am managing with A

4条回答
  •  眼角桃花
    2020-12-02 07:08

    The problem is resolved by removing this line from the playbook:

    sudo: yes
    

    When sudo is run on the remote host, the environment variables set by ssh during login are no longer available. In particular, SSH_AUTH_SOCK, which "identifies the path of a UNIX-domain socket used to communicate with the agent" is no longer visible so ssh agent forwarding does not work.

    Avoiding sudo when you don't need it is one way to work around the problem. Another way is to ensure that SSH_AUTH_SOCK sticks around during your sudo session by creating a sudoers file:

    /etc/sudoers:
    
         Defaults    env_keep += "SSH_AUTH_SOCK"
    

提交回复
热议问题