Conemu ssh 导致“不会分配伪终端,因为 stdin 不是终端”

Conemu ssh 导致“不会分配伪终端,因为 stdin 不是终端”

我正在使用 Conemu 任务通过 ssh 连接到我的服务器。为了使我的 motd 生成器支持 256 色,我已将 cygwin-connector conemu-cyg-64.exe 放在我的台式机和笔记本电脑上的 CygWin 安装的 bin 文件夹中。(https://github.com/Maximus5/cygwin-connector

在我的桌面上,以下任务运行完美:

conemu-cyg-64.exe -cur_console:h0 ssh [email protected]

在我的笔记本电脑上,使用相同的命令和相同的设置,出现此错误:

Pseudo-terminal will not be allocated because stdin is not a terminal

我尝试了很多方法,比如完全重新安装 CygWin、更改 openssh 版本。我尝试了版本 7.1p1-1 和版本 6.9p1-1。我尝试的所有方法都给出了相同的错误,除非我使用带有 -tt 参数的 ssh 命令。

conemu-cyg-64.exe -cur_console:h0 ssh -tt [email protected]

但这会导致其他问题,因为当使用 -tt 时,制表符补全似乎不再起作用,并且箭头给出 OA OC OB OD 作为结果。

使用空白连接器时

conemu-cyg-64.exe -cur_console:h0

无需 ssh 命令:

ssh -V
OpenSSH_7.1p1, OpenSSL 1.0.2e 3 Dec 2015


which ssh
/usr/bin/ssh

配置与我的桌面上完全相同,问题中的第一个任务运行完美。当我打开任务“conemu-cyg-64.exe -cur_console:h0”然后粘贴“ssh[电子邮件保护]' 有用。

欢迎提出任何想法或提示来解决这个问题,以便它与任务中的 ssh 一起工作。从桌面上的 Cmd(cmd.exe /k“%ConEmuBaseDir%\CmdInit.cmd”):

> conemu-cyg-64.exe --verbose ssh [email protected]
{PID:19148} declaring TERM: `xterm-256color` (was: `cygwin`)
{PID:19148} current $HOME is `/cygdrive/c/Users/Willem`
{PID:19148} 0: isatty()=1; pgrp=19148; ttyname()=`/dev/cons0`
{PID:19148} 1: isatty()=1; pgrp=19148; ttyname()=`/dev/cons0` 
{PID:19148} 2: isatty()=1; pgrp=19148; ttyname()=`/dev/cons0`
{PID:19148} calling fork (pgid=19148)
{PID:19148} child pid=23540 pgid=19148 was created (ourpgid=19148)
{PID:19148} PTY was created: `/dev/pty0`; Child PID:23540
{PID:19148} 0: isatty()=1; pgrp=19148; ttyname()=`/dev/cons0`
{PID:19148} 1: isatty()=1; pgrp=19148; ttyname()=`/dev/cons0`
{PID:19148} 2: isatty()=1; pgrp=19148; ttyname()=`/dev/cons0` 
{PID:19148} raising SIGUSR1 in pid=23540
{PID:19148} SIGUSR1 received
{PID:23540} child created (pgid=23540)
{PID:23540} child process wating for SIGUSR1 (pgid=23540)
{PID:23540} SIGUSR1 received
{PID:23540} child process continues after 0 ms (SIGUSR1=1)
{PID:23540} ttyname(1)=`/dev/pty0`
{PID:23540} ttyname(1)=`/dev/pty0`
{PID:23540} 0: isatty()=1; pgrp=23540; ttyname()=`/dev/pty0`
{PID:23540} 1: isatty()=1; pgrp=23540; ttyname()=`/dev/pty0`
{PID:23540} 2: isatty()=1; pgrp=23540; ttyname()=`/dev/pty0`
{PID:23540} raising SIGUSR1 in pid=19148
{PID:23540} shell: `ssh` `[email protected]`
{PID:23540}   dir: `/cygdrive/c/Users/Willem`
Last login: Thu Jan  7 18:56:29 2016 from 78-21-31-4.access.telenet.be

在我的桌面上:echo $TERM xterm-256color

在笔记本电脑上:

$ conemu-cyg-64.exe --verbose ssh [email protected]
{PID:13184} declaring TERM: `xterm-256color` (was: `cygwin`)
{PID:13184} current $HOME is `/cygdrive/c/Users/willem/`
{PID:13184} 0: isatty()=1; pgrp=13184; ttyname()=`/dev/cons0`
{PID:13184} 1: isatty()=1; pgrp=13184; ttyname()=`/dev/cons0`
{PID:13184} 2: isatty()=1; pgrp=13184; ttyname()=`/dev/cons0`
{PID:13184} calling fork (pgid=13184)
{PID:13184} child pid=8680 pgid=13184 was created (ourpgid=13184)
{PID:13184} PTY was created: `/dev/pty0`; Child PID:8680
{PID:13184} 0: isatty()=1; pgrp=13184; ttyname()=`/dev/cons0`
{PID:13184} 1: isatty()=1; pgrp=13184; ttyname()=`/dev/cons0`
{PID:13184} 2: isatty()=1; pgrp=13184; ttyname()=`/dev/cons0`
{PID:13184} raising SIGUSR1 in pid=8680
{PID:13184} SIGUSR1 received
{PID:8680} child created (pgid=8680)
{PID:8680} child process wating for SIGUSR1 (pgid=8680)
{PID:8680} SIGUSR1 received
{PID:8680} child process continues after 16 ms (SIGUSR1=1)
{PID:8680} ttyname(1)=`/dev/pty0`
{PID:8680} ttyname(1)=`/dev/pty0`
{PID:8680} 0: isatty()=1; pgrp=8680; ttyname()=`/dev/pty0`
{PID:8680} 1: isatty()=1; pgrp=8680; ttyname()=`/dev/pty0`
{PID:8680} 2: isatty()=1; pgrp=8680; ttyname()=`/dev/pty0`
{PID:8680} raising SIGUSR1 in pid=13184
{PID:8680} shell: `ssh` `[email protected]`
{PID:8680}   dir: `/cygdrive/c/Users/willem`
Pseudo-terminal will not be allocated because stdin is not a terminal.
pwd
/home/user
echo $TERM

pwd
/home/user

笔记本电脑上的 /usr/bin/sh -c“set”:

$ conemu-cyg-64.exe --verbose --shlvl /usr/bin/sh -c "set"
{PID:5788} declaring TERM: `xterm-256color` (was: `cygwin`)
{PID:5788} current $HOME is `/cygdrive/c/Users/willem/`
{PID:5788} 0: isatty()=1; pgrp=5788; ttyname()=`/dev/cons0`
{PID:5788} 1: isatty()=1; pgrp=5788; ttyname()=`/dev/cons0`
{PID:5788} 2: isatty()=1; pgrp=5788; ttyname()=`/dev/cons0`
{PID:5788} calling fork (pgid=5788)
{PID:5788} child pid=19116 pgid=5788 was created (ourpgid=5788)
{PID:5788} PTY was created: `/dev/pty0`; Child PID:19116
{PID:5788} 0: isatty()=1; pgrp=5788; ttyname()=`/dev/cons0`
{PID:5788} 1: isatty()=1; pgrp=5788; ttyname()=`/dev/cons0`
{PID:5788} 2: isatty()=1; pgrp=5788; ttyname()=`/dev/cons0`
{PID:5788} raising SIGUSR1 in pid=19116
{PID:19116} child created (pgid=19116)
{PID:19116} child process wating for SIGUSR1 (pgid=19116)
{PID:19116} SIGUSR1 received
{PID:19116} child process continues after 15 ms (SIGUSR1=1)
{PID:19116} ttyname(1)=`/dev/pty0`
{PID:19116} ttyname(1)=`/dev/pty0`
{PID:19116} 0: isatty()=1; pgrp=19116; ttyname()=`/dev/pty0`
{PID:19116} 1: isatty()=1; pgrp=19116; ttyname()=`/dev/pty0`
{PID:19116} 2: isatty()=1; pgrp=19116; ttyname()=`/dev/pty0`
{PID:19116} raising SIGUSR1 in pid=5788
{PID:19116} shell: `/usr/bin/sh` `-c` `set`
{PID:19116}   dir: `/cygdrive/c/Users/willem`
{PID:5788} SIGUSR1 received
ALLUSERSPROFILE='C:\ProgramData'
ANSICON='118x4000 (118x28)'
ANSICON_DEF=7
APPDATA='C:\Users\willem\AppData\Roaming'
BASH=/usr/bin/sh
BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="3" [2]="42" [3]="4" [4]="release" [5]="x86_64-unknown-cygwin")
BASH_VERSION='4.3.42(4)-release'
COMMONPROGRAMFILES='C:\Program Files\Common Files'
COMPUTERNAME=NBDIG50009
COMSPEC='C:\Windows\system32\cmd.exe'
ChocolateyBinRoot='\bin'
ChocolateyInstall='C:\ProgramData\chocolatey'
CommonProgramW6432='C:\Program Files\Common Files'
ConEmuANSI=ON
ConEmuAnsiLog=
ConEmuArgs=
ConEmuBackHWND=0x000D1506
ConEmuBaseDir='C:\Users\willem\Dropbox\Utilities\ConEmu\ConEmu'
ConEmuBuild=151224
ConEmuConfig=
ConEmuDir='C:\Users\willem\Dropbox\Utilities\ConEmu'
ConEmuDrawHWND=0x000A0C8C
ConEmuDrive=C:
ConEmuHWND=0x0040183C
ConEmuHooks=Enabled
ConEmuIsAdmin=ADMIN
ConEmuPID=14444
ConEmuPrompt0='$E[32m$E]9;8;"USERNAME"$E\@$E]9;8;"COMPUTERNAME"$E\$S'
ConEmuPrompt1='$E[32m$E]9;8;"USERNAME"$E\@$E]9;8;"COMPUTERNAME"$E\$S$E[92m$P$E[90m'
ConEmuPrompt2='$_$E[90m$$'
ConEmuPrompt3='$E[m$S'
ConEmuServerPID=12516
ConEmuWorkDir='C:\Users\willem'
ConEmuWorkDrive=C:
DEFLOGDIR='C:\ProgramData\McAfee\DesktopProtection'
DIRSTACK=()
EUID=1077902
FP_NO_HOST_CHECK=NO
GROUPS=()
HOME=/cygdrive/c/Users/willem/
HOMEDRIVE=H:
HOMEPATH='\'
HOMESHARE='\\userdrive\home'
HOSTNAME=NBDIG50009
HOSTTYPE=x86_64
IFS='
'
LOCALAPPDATA='C:\Users\willem\AppData\Local'
LOGONSERVER='\\DC01'
MACHTYPE=x86_64-unknown-cygwin
NUMBER_OF_PROCESSORS=4
OPTERR=1
OPTIND=1
OS=Windows_NT
OSTYPE=cygwin
PATH='/cygdrive/c/Users/willem/Dropbox/Utilities/ConEmu/ConEmu/Scripts:/cygdrive/c/Users/willem/Dropbox/Utilities/ConEmu:/cygdrive/c/Users/willem/Dropbox/Utilities/ConEmu/ConEmu:/cygdrive/c/Perl64/site/bin:/cygdrive/c/Perl64/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/cygdrive/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.0:/cygdrive/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/cygdrive/c/Program Files (x86)/Git/cmd:/cygdrive/c/Program Files (x86)/Git/bin:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/Tools/Binn/ManagementStudio:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/Tools/Binn:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/cygdrive/c/Program Files/TortoiseHg:/cygdrive/c/Program Files/SourceGear/Common/DiffMerge:/cygdrive/c/Program Files (x86)/Skype/Phone:/usr/bin:/cygdrive/c/Users/willem/AppData/Local/atom/bin:/cygdrive/c/Users/willem/AppData/Local/atom/bin:/cygdrive/c/tools/cmder:/cygdrive/c/Program Files/Boot2Docker for Windows'
PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
POSIXLY_CORRECT=y
PPID=5788
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER='Intel64 Family 6 Model 60 Stepping 3, GenuineIntel'
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=3c03
PROGRAMFILES='C:\Program Files'
PROMPT='$E[32m$E]9;8;"USERNAME"$E\@$E]9;8;"COMPUTERNAME"$E\$S$E[92m$P$E[90m$_$E[90m$$$E[m$S'
PS4='+ '
PSModulePath='C:\Users\willem\Documents\WindowsPowerShell\Modules'
PUBLIC='C:\Users\Public'
PWD=/cygdrive/c/Users/willem
ProgramData='C:\ProgramData'
ProgramW6432='C:\Program Files'
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=2
SYSTEMDRIVE=C:
SYSTEMROOT='C:\Windows'
TEMP=/cygdrive/c/Users/willem/AppData/Local/Temp
TERM=xterm-256color
TMP=/cygdrive/c/Users/willem/AppData/Local/Temp
UID=1077902
USERDNSDOMAIN=DOMAIN
USERDOMAIN=DOMAIN
USERDOMAIN_ROAMINGPROFILE=DOMAIN
USERNAME=willem
USERPROFILE='C:\Users\willem'
VBOX_MSI_INSTALL_PATH='C:\Program Files\Oracle\VirtualBox\'
VS120COMNTOOLS='C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\'
VSEDEFLOGDIR='C:\ProgramData\McAfee\DesktopProtection'
WINDIR='C:\Windows'
WIX='C:\Program Files (x86)\WiX Toolset v4.0\'
_=/usr/bin/sh
chocolatey_bin_root='\bin'
windows_tracing_flags=3
windows_tracing_logfile='C:\BVTBin\Tests\installpackage\csilogfile.log'

{PID:5788} read(3) failed (5): Input/output error

{PID:5788} pty_fd set to -1

{PID:5788} pid=19116 was terminated, exitcode=0
{PID:5788} Stopping our threads

{PID:5788} normal exit from main

您的最后建议为我指明了正确的方向。 Process Explorer 显示 C:\Program Files (x86)\Git\bin 中的 ssh.exe 已被使用

显示 Git 中的 ssh.exe 的进程资源管理器图像

正如 Maximus 在他的回答中所建议的那样,在我的任务中使用 /usr/bin/ssh 解决了这个问题!

答案1

相当奇怪。首先要检查的是TERM变量。为简单起见,您可以忽略并从ConEmu 中启动的-cur_console:h0裸提示运行测试。cmd.exe

尝试在两台电脑上运行并比较它们的输出。

conemu-cyg-64.exe --verbose ssh [email protected]

尝试检查ssh没有配置文件的环境变量设置,sh set在两台电脑上运行该变量并比较输出。

conemu-cyg-32.exe --verbose --shlvl /usr/bin/sh -c "set"

最后,你必须确保它ssh从正确的位置启动。你甚至可以/usr/bin/ssh ...为此专门运行。使用 ProcessExplorer 检查它。

相关内容