当我使用 heredoc 并将所有命令放在 heredoc 中时,
ssh -t -i master.pem cloud-user@$1 <<EOSSH
sudo service x restart
sudo service y restart
EOSSH
Run Code Online (Sandbox Code Playgroud)
它抛出错误,
Pseudo-terminal will not be allocated because stdin is not a terminal.
Run Code Online (Sandbox Code Playgroud)
当我添加另一个 -t 选项时,效果很好,
ssh -t -t -i master.pem cloud-user@$1 <<EOSSH
sudo service x restart
sudo service y restart
EOSSH
Run Code Online (Sandbox Code Playgroud)
pseudo-terminal
在 ssh 会话的上下文中是什么意思?
stdin is not a terminal
- bash 不为 ssh 客户端提供标准输入终端吗?
-t
option 是什么意思,和 有什么-t -t
不同-t
?
正如中所解释的man ssh
:
\n\n-t 强制伪 tty 分配。这可用于
\n
在远程计算机上执行 arbi\xe2\x80\x90\n 基于屏幕的程序,这
\n 非常有用,例如在实现菜单服务时。 多个 -t
\n 选项强制 tty 分配,即使 ssh 没有本地 tty。