Docker内Deployer启动远程SSH会话遇input device is not a TTY错误
问题解决:Deployer脚本开启SSH会话时"the input device is not a TTY"错误
核心问题分析
你脚本中使用了ssh -T命令,其中-T参数的作用是强制禁用伪终端请求,这和你要开启交互式SSH会话的需求完全冲突。而手动执行ssh {remoteUser}@{hostname}时没有该参数,所以能正常获取TTY。
解决方案
修改脚本,移除-T参数,确保runLocally的tty选项正确启用:
task('remotessh', function () { $host = currentHost(); $hostname = $host->getHostname(); $remoteUser = $host->get('remote_user'); if (!$remoteUser) { throw new \RuntimeException("Remote user not set for host."); } // 移除-T参数,允许SSH请求伪终端 $sshCommand = "ssh $remoteUser@$hostname"; // 若仍有问题,可替换为-tt强制分配TTY:$sshCommand = "ssh -tt $remoteUser@$hostname"; runLocally($sshCommand, ['tty' => true]); });
补充说明
- 若去掉
-T后依然报错,可改用-tt参数:该参数会强制SSH分配伪终端,适用于部分Docker环境下TTY检测异常的场景。 - 修改后在Docker终端执行
dep remotessh(根据你的Deployer命令调整),即可正常进入远程SSH会话。
内容的提问来源于stack exchange,提问作者warm__tape
相关产品推荐
相关产品推荐

