Hi Ajay,

I tried with -k, it does not work

netadmin@netadmin-Virtual-Machine:/etc/ansible$ ansible-playbook ios.yml -k
SSH password:

PLAY [10.11.32.100] ********************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************
 [WARNING]: sftp transfer mechanism failed on [10.11.32.100]. Use ANSIBLE_DEBUG=1 to see detailed information
 [WARNING]: scp transfer mechanism failed on [10.11.32.100]. Use ANSIBLE_DEBUG=1 to see detailed information
fatal: [10.11.32.100]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to remote host \"10.11.32.100\". Make sure this host can be reached over ssh", "unreachable": true}
 [WARNING]: Could not create retry file '/etc/ansible/ios.retry'.         [Errno 13] Permission denied: u'/etc/ansible/ios.retry'

PLAY RECAP *****************************************************************************************************************************************************************************************
10.11.32.100               : ok=0    changed=0    unreachable=1    failed=0  

Here is the output of -vvv
netadmin@netadmin-Virtual-Machine:/etc/ansible$ ansible-playbook ios.yml -vvv
ansible-playbook 2.5.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/netadmin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin

PLAYBOOK: ios.yml **********************************************************************************************************************************************************************************
1 plays in ios.yml

PLAY [10.11.32.100] ********************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************
task path: /etc/ansible/ios.yml:2
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<10.11.32.100> ESTABLISH SSH CONNECTION FOR USER: 60081064
<10.11.32.100> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=60081064 -o ConnectTimeout=10 -o ControlPath=/home/netadmin/.ansible/cp/e0e6fa081f 10.11.32.100 '/bin/sh -c '"'"'echo ~60081064 && sleep 0'"'"''
<10.11.32.100> (255, '', '[EMAIL PROTECTED]: Permission denied (publickey,keyboard-interactive,password).\r\n')
fatal: [10.11.32.100]: UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: [EMAIL PROTECTED]: Permission denied (publickey,keyboard-interactive,password).\r\n",
    "unreachable": true
}
 [WARNING]: Could not create retry file '/etc/ansible/ios.retry'.         [Errno 13] Permission denied: u'/etc/ansible/ios.retry'

PLAY RECAP *****************************************************************************************************************************************************************************************
10.11.32.100               : ok=0    changed=0    unreachable=1    failed=0  

netadmin@netadmin-Virtual-Machine:/etc/ansible$

Sent from Mail for Windows 10

From: Ajay Kumar Manukonda
Sent: Friday, 10 August 2018 9:59 AM
To: [EMAIL PROTECTED]
Subject: Re: [ansible-project] Re: cannot login to cisco switch using ansible

Hi Michael,

"ansble all -m ping , it gives the same error  Permission denied (publickey,keyboard-interactive,password)"  doesn't work because ansible ping module requires the remote node to run python. You can find more about it here: https://docs.ansible.com/ansible/latest/modules/ping_module.html#ping-module

So, it works for your username, and based on "Failed to connect to the host via ssh: [EMAIL PROTECTED]: Permission denied (publickey,keyboard-interactive,password)" ansible is using the correct username. Where are you defining your password? In the hosts file? If that is the case, hash the password in the hosts file and use -k option instead ( ansible-playbook ios.yml -k ) and enter the password manually just to eliminate one source of the problem.

If that doesn't work, revert the changes and get the output of "ansible-playbook ios.yml -vvvv " command. It could help us find the source of the issue.

Regards,
Ajay

On Thu, Aug 9, 2018 at 1:35 PM Michael Sawires <[EMAIL PROTECTED]> wrote:
Hi Ajay,

If username is 60081064, it works, if root, it does not.

Thanks,
Michael 

On Fri, 10 Aug 2018 at 4:41 am, Ajay Kumar Manukonda <[EMAIL PROTECTED]> wrote:
Hi Michael,

By looking at this error : "msg": "Failed to connect to the host via ssh: [EMAIL PROTECTED]: Permission denied (publickey,keyboard-interactive,password).\r\n", "unreachable": true it seems like your ansible VM can not SSH to the cisco switch in the first place.

Does normal SSH to the switch work? like if you do ssh [EMAIL PROTECTED] . If it doesn't work, you have to fix that first. Maybe the switch is allowing connections only from particular IP addresses.

Regards,
Ajay

On Thu, Aug 9, 2018 at 8:02 AM Michael Sawires <[EMAIL PROTECTED]> wrote:
Hi Ajay,

I was able to build a new machine, still having same issue ansible & ssh permissio