Erratic SSH Connection

29 views
Skip to first unread message

Manoj Govindan

unread,
Jun 19, 2015, 10:47:13 AM6/19/15
to ansible...@googlegroups.com
Consider the following two commands:

(1) ansible-playbook --limit dtest  --private-key=/path/to/private/key.pem test_stat.yml
(2) ansible-playbook --limit dtest test_stat.yml

The test_stat playbook is given below:

# An ANSIBLE playbook to execute stat
- name: Play - Stat
  hosts: all
  vars_files:
    - "ssh_server_static_keys/{{ inventory_hostname }}.yml"
  roles:
    - stat

I have a file named ssh_server_static_keys/dtest.yml that contains something like this.

ssh_host_rsa_key: |
    -----BEGIN RSA PRIVATE KEY-----
    .....
    -----END RSA PRIVATE KEY-----

If I execute the commands (1), followed by (2), both work. 
Executing (1) creates a socket named $HOME/.ansible/cp/ansible-ssh-<something>
As long as that socket is alive, (2) works. 

If I execute (2) alone, it doesn't work. I get the following error:
fatal: [dtest] => SSH Error: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
    while connecting to <host>:<port>

However, (2) alone works without any error for *another* host, which has a key in ssh_server_static_keys/something.yml.

What am I missing? 

Thanks,
Manoj

Brian Coca

unread,
Jun 22, 2015, 10:41:36 AM6/22/15
to ansible...@googlegroups.com
No, unless I'm missing something, this is how ssh works. ControlPersist/Master allows you to reuse the connection so you don't need to re-authenticate. But if you never authenticated ... there is nothing to reuse.

--------
Brian Coca


--
Brian Coca

Reply all
Reply to author
Forward
0 new messages