willhallonline / docker-ansible

Ansible inside Docker containers: Alpine, Ubuntu, Rocky & Debian with Ansible 2.16, 2.15, 2.14, 2.13, 2.12, 2.11, 2.10 and 2.9 + Mitogen
https://www.willhallonline.co.uk/project/docker/docker-ansible/
MIT License
376 stars 135 forks source link

SSH-KEY #26

Closed nickkostov closed 4 years ago

nickkostov commented 4 years ago

When attempting to run playbook, I am unable to ssh into the hosts: all of them have root log in turned on:

`/ansible # ssh-copy-id root@ip /usr/bin/ssh-copy-id: ERROR: No identities found /ansible # ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:k5DL7cRJYsUnaYTFFgZEL9MeoRI1xKsJqNgNbffZlGM root@7b0947e308c0 The key's randomart image is: +---[RSA 3072]----+ | .*BBBo |

+----[SHA256]-----+ /ansible # ls hosts playbook.yml /ansible # ssh-copy-id root@ip /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed expr: warning: '^ERROR: ': using '^' as the first character of a basic regular expression is not portable; it is ignored /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@ip's password: Permission denied, please try again. root@ip's password:`

willhallonline commented 4 years ago

Hi @nemame , I am not sure that I fully understand the issue (which is probably my ignorance). What I would suggest is that you should mount the ssh-key that you are using on your local machine into the container rather than generating within the container. The container by its nature should be short-lived and normally should not put anything into the container that you want to keep.