【问题标题】:pass the password as an argument in pssh在 pssh 中将密码作为参数传递
【发布时间】:2017-09-21 16:15:51
【问题描述】:

我正在尝试编写一个脚本,该脚本将使用pssh 在多台机器上运行命令。 有没有办法在下面的同一命令行中传递密码:

$ pssh -h pssh-host.txt -l root -A "pswd" echo "hi"
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:

尝试了以下解决方案:

sshpass -pabc pssh -h pssh-host.txt -l root -A echo "hi"
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
[1] 13:55:56 [SUCCESS] x
[2] 13:55:56 [SUCCESS] y

我不想要这个Password: 提示。有人可以为此建议一种方法吗?

【问题讨论】:

  • 两个链接都试过了,都没有用。还有其他解决方案吗?
  • @Peter,您可以将解决方案粘贴为答案,我会接受,非常感谢!成功了!
  • 顺便说一句,将密码作为命令行参数传递给系统上的所有其他用户(包括不受信任的用户,例如nobody)。可以重写 argv,但只有在启动完成后才能重写,这意味着即使程序 尝试 阻止同样的情况,也会有一个不可避免的暴露窗口。考虑使用环境变量(如果你的操作系统——比如现代 Linux——保护它们不被其他用户读取)。

标签: python python-2.7 pssh


【解决方案1】:

an answer by user568109 on Unix SE 交叉发布为社区 Wiki:


发布问题后不久在网上找到了解决方案。

解决办法是:

  1. 安装和使用 sshpass
  2. 使用交互模式强制输入只是一个空字符串的密码
  3. 使用的命令cat local | sshpass -ppassword parallel-ssh -I -h new_hosts -l root -A 'cat >> remote'

原始解决方案位于: http://www.getreu.net/public/downloads/doc/Secure_Computer_Cluster_Administration_with_SSH/

【讨论】:

    猜你喜欢
    • 2018-10-21
    • 2011-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-05
    • 2015-12-09
    • 2021-11-17
    相关资源
    最近更新 更多