passphrase prompted on private_key
MacFlurry opened this issue · 2 comments
Hello,
First of all I wanted to thank you for your work.
I hope you could help me.
I have Docker for mac (version 2.2.0.5)
I have in my inventory file:
[group1]
xx.xx.xx.xx
[group2]
xx.xx.xx.xx ansible_port=811
[vps:children]
group1
group2
[vps:vars]
ansible_ssh_user=myuser
ansible_ssh_private_key_file=~/Documents/personal_server/myKey_rsa
I run my docker like this:
docker run --rm -it \
-v ~/.ssh:/root/.ssh \
-v ${HOME}/Documents/personal_server/:/ansible/ \
-v "$SSH_AUTH_SOCK":"/root/$(basename $SSH_AUTH_SOCK)" \
-e SSH_AUTH_SOCK="/root/$(basename $SSH_AUTH_SOCK)" \
-e HOST_KEY_CHECKING=False \
cytopia/ansible:latest-infra ansible vps -i /ansible/myinventory -b -m ping
ssh asks me to enter the passphrase every time.
With one server, it's ok, but when you have about 20 servers, it becomes complicated to enter the passphrase for each iteration.
INFO] root> ansible vps -i /ansible/myinventory -b -m ping
Enter passphrase for key '/root/.ssh/myKey_rsa': Enter passphrase for key '/root/.ssh/myKey_rsa':
Thank you for your help.
I use following on mac:
In host system (your mac) add the rsa to ssh-agent
cd ~
export SSH_AUTH_SOCK="$(launchctl getenv SSH_AUTH_SOCK)"
ssh-add .ssh/id_rsa
echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" > .ssh/agent
and mount created socket to docker
...
-v "/run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock"\
-e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \
...
or second option, if you don't want to mess with sockets mounting, you can fire-up ssh-agent in docker container and load mounted key there, so you only need to enter the password once for every container start instead of 20. Just my 2¢
Hello,
I should have closed it earlier.
I solved this by using this
-v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock \
-e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \
Thanks