Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForwardAgent option does not work #65

Closed
trocho opened this issue Jan 26, 2021 · 3 comments
Closed

ForwardAgent option does not work #65

trocho opened this issue Jan 26, 2021 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@trocho
Copy link

trocho commented Jan 26, 2021

Context
I share my local ~/.shh directory to the ansible-tool image this way.
alias ansible-playbook='docker run --rm -it -e USER=ansible -e MY_UID=1000 -e MY_GID=1000 -v ${HOME}/.ssh/:/home/ansible/.ssh/ -v $(pwd):/data cytopia/ansible:latest-tools ansible-playbook'

The problem is
And I'm trying to clone my git repo and I get Cloning into '/var/www'...\[email protected]: Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.

sshd config at server

cat /etc/ssh/sshd_config | grep AllowAgentForwarding
AllowAgentForwarding yes

the shared local ssh config ~/.ssh/config

Host *
    StrictHostKeyChecking no
    ForwardAgent yes

ansible.cfg

[ssh_connection]
ssh_args= -o ForwardAgent=yes -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=60s

/etc/sudoers

cat /etc/sudoers | grep SSH
Defaults env_keep += "SSH_AUTH_SOCK"

When I connect to the server via ssh traditionally the forwarding of my local ssh key work correctly and the cloning of git repo works.

@cytopia
Copy link
Owner

cytopia commented Mar 25, 2021

@trocho just to be able to fully reproduce this on my end, do you have a password set on your key?

@cytopia cytopia self-assigned this Mar 25, 2021
@Sylvain303
Copy link

@trocho

if the ssh agent run outside docker, you have to also pass the socket and export a new SSH_AUTH_SOCK to the mounted volume.

docker "your other options"   \
  -v $SSH_AUTH_SOCK:/ssh-agent --env SSH_AUTH_SOCK=/ssh-agent \
  "other stuff for docker cmd"

hope that helps.

@cytopia cytopia added the documentation Improvements or additions to documentation label Nov 4, 2021
@cytopia
Copy link
Owner

cytopia commented Feb 1, 2023

I have added this to the Readme's documentation: #125

Thanks @Sylvain303 for the ssh-agent mount !

@cytopia cytopia closed this as completed in c2a1fa1 Feb 1, 2023
cytopia added a commit that referenced this issue Feb 1, 2023
Fixes #65 Document SSH agent usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants