gpt4 book ai didi

ssh - "Force psuedo-tty allocation"不能转换为 pssh

转载 作者:行者123 更新时间:2023-12-04 21:25:27 28 4
gpt4 key购买 nike

据说,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

最佳答案

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

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

ssh man page说这个关于“-t”(强调):

-t
Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.



您显然以 ssh 没有本地 tty 的方式运行 pssh。因此,您必须安排 ssh 以“-t”指定两次运行。这会强制 ssh 请求远程 tty,尽管没有本地 tty。

关于ssh - "Force psuedo-tty allocation"不能转换为 pssh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37197482/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com