ansible ssh error to ec2-instance

I am able to ssh to an ec2 instance using putty and .ppk file.

when trying to do the same from build server, i am getting ssh error

things that i have tried

  1. inventory file:

[aws-hosts]
10.20.30.40 [ changed ip for the post]

[aws-hosts:vars]
ansible_ssh_private_key_file=/tmp/devhosts.ppk

then ran
ansible aws-hosts -u ec2-user -i invent -m ping

getting the below error

ESTABLISH SSH CONNECTION FOR USER: ec2-user
SSH: EXEC ssh -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey,keyboard-interactive -o ControlMaster=auto -o ControlPersist=300 -o StrictHostKeyChecking=no -o ‘IdentityFile=“/tmp/devhosts.ppk”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ec2-user -o ConnectTimeout=120 -o ControlPath=/home/xxxxx/.ansible/cp/7f5a8fa6ee xxxxxx ‘/bin/sh -c ‘"’"’/usr/bin/python && sleep 0’“'”‘’
xxxxxxxx | UNREACHABLE! => {
“changed”: false,
“msg”: “SSH Error: data could not be sent to remote host "xxxxxxxxx". Make sure this host can be reached over ssh”,
“unreachable”: true
}

replaced ip with ‘xxxxxxx’

  1. tried to replace the ppk file in the inventory file with .pem file still same error

  2. tried --key-file in the ansible command line instead of the inventory file.

  3. tried --private-key in the ansible command line

get the same error for all.

try this sed -i ‘/[ssh_connection/ s/$/ \nscp_if_ssh = True/’ ansible.cfg

sed -i ‘/[ssh_connection/s/$/\nscp_if_ssh=True/’ ansible.cfg
sed: -e expression #1, char 39: unterminated address regex

i added this line manually
nscp_if_ssh=True

but still same error

its not nscp , just scp pl check