A pound '#' sign in password

17 views
Skip to first unread message

xinhua...@gmail.com

unread,
Nov 25, 2020, 11:51:54 AM11/25/20
to Ansible Project
We want to use ansible to connect to a managed device. We have created a host_var file with the username and the password. Here is the host_var/mydevice file:

---
username: myuser
password: secret#secret

We used below ansible command to connect to mydevice:

ansible mydevice -vvvv -u myuser -m raw -a "ping 1.2.3.4"

However, we are getting the authentication error like below:

mydevice | UNREACHABLE! => {
   "changed": false, 
   "msg": "Failed to authenticate: Authentication failed.", 
   "unreachable": true
}

When we connect to mydevice using ssh connection, we type in the password and the device accepts it without problem. We are able to connect.

When  add -k switch to ansible command, type in the password, getting the same authentication failure.

Also tried using back slash symbol '\' and double back slash symbol '\\' before '#' symbol. Does NOT work either.

Is it because the '#' symbol issue? How do we escape it?

Thank you,

- Xinhuan

Felix Fontein

unread,
Nov 25, 2020, 12:08:14 PM11/25/20
to ansible...@googlegroups.com
Hi,

have you tried adding quotes?

> username: myuser
> password: 'secret#secret'

Otherwise YAML might interpret everything after # as a comment.

Cheers,
Felix


Reply all
Reply to author
Forward
0 new messages