“强制伪造分配”并没有转化为pssh

时间:2016-05-12 21:13:14

标签: ssh python-3.4 remote-access

据说,pssh的-x选项传递额外的SSH命令行参数。 SSH的“-t”选项应该处理“伪终端”错误。是否应该使用另一个pssh / ssh选项?

# pssh -i -H ec2-user@xxx.xxx.xxx.xx1 -H ec2-user@xxx.xxx.xxx.xx2 -x "-t -i /tmp/key.pem" 'sudo hostname'
[1] 13:46:54 [FAILURE] ec2-user@xxx.xxx.xxx.xx1 Exited with error code 1
Stderr: Pseudo-terminal will not be allocated because stdin is not a terminal.
sudo: sorry, you must have a tty to run sudo
[2] 13:46:54 [FAILURE] ec2-user@xxx.xxx.xxx.xx1 Exited with error code 1
Stderr: Pseudo-terminal will not be allocated because stdin is not a terminal.
sudo: sorry, you must have a tty to run sudo

没有“-t”和“sudo”,命令工作正常,但我需要以sudo的身份运行一些命令。

# pssh -i -H ec2-user@xxx.xxx.xxx.xx1 -H ec2-user@xxx.xxx.xxx.xx2 -x "-i /tmp/key.pem" 'hostname'
[1] 14:08:35 [SUCCESS] ec2-user@xxx.xxx.xxx.xx1
ip-10-0-0-140
[2] 14:08:35 [SUCCESS] ec2-user@xxx.xxx.xxx.xx2
ip-10-0-0-139

1 个答案:

答案 0 :(得分:6)

尝试像这样运行pssh,以便指定“-t”选项两次:

pssh -i -H ec2-user@... -x "-t -t -i /tmp/key.pem" 'sudo hostname'
                            ^^^^^

ssh man page说的是关于“-t”(强调补充):

  

-t
  强制伪终端分配。这可以用来执行任意的   基于屏幕的程序在远程机器上,可以是非常的   有用的,例如实现菜单服务时。 多个-t选项   强制tty分配,即使ssh没有本地tty。

你显然正在运行pssh,以至于ssh没有本地tty。所以你必须安排ssh运行两次指定“-t”。这迫使ssh请求远程tty,尽管没有本地tty。