shell - 如何在 @ 中使用密码!# ansible shell ssh 中的字符?
问题描述
我正在尝试通过 SSH 在一堆远程服务器上运行一些简单的检查。没有什么花哨。其中一台服务器的密码类似于mY*test@2PAss!01lZ#
我的库存.yml
文件。
对于这个特定的服务器,我得到:
SRV1 | UNREACHABLE! => {
"changed": false,
"msg": "Invalid/incorrect password: Failed to add the host to the list of known hosts (/home/redacted/.ssh/known_hosts).\r\n------------------------------------------------------------------------------\n* WARNING *\n* You are accessing a secured system and your actions will be logged along *\n* with identifying information. Disconnect immediately if you are not an *\n* authorized user of this system. *\n------------------------------------------------------------------------------\nPermission denied, please try again.",
"unreachable": true
}
我尝试过的所有事情都不起作用:
- 转义或, , ,字符
mY*test\@2PAss\!01lZ\#
的任何其他组合*
@
!
#
- 使用 ansible 保险库
- 使用
ansible_ssh_pass: "{{ i_pass | regex_escape() }}"
- 单/双引号
我没主意了。
有人遇到过类似的问题吗?
信息:
- 可靠的 2.9.6
python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
- 从 Ubuntu 连接到 RHEL 盒子
- 使用没有这种“特殊”字符的密码与另一个 RHEL 盒子的类似连接工作正常
- 我无法定义公钥/私钥或更改密码。目标盒子由另一个团队安装和配置,然后该盒子在多个其他团队之间共享。
解决方案
使用公钥认证更容易,因此您不需要任何密码。
关于特殊字符,我做了一个测试:
ansible localhost -m command -a "echo '{{ a }}'" -e '{"a": "mY*test@2PAss!01lZ#"}'
localhost | CHANGED | rc=0 >>
mY*test@2PAss!01lZ#
所以这不是一般问题。
推荐阅读
- python - 图像转换:(150,150) -> (150,150,3)
- python - Python中的全局变量以及如何避免它们?
- python - 为列表列表赋值
- c++ - C ++从文本文件中读取字符串并将逐字保存到链表中
- swift - 使用 SFSafariViewController 缓存网站以供离线使用
- linux - 稳定安装 - (读取 rustc 版本时出错)
- razor - asp.net核心剃须刀页面中的防伪令牌?
- ios - iPhone 设备轮换上的弹出窗口更改
- makefile - 使用 makefile 进行自动化测试
- java - 在java中安排任务和监视它们的最佳方法是什么