-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetConsoleMode error #856
Comments
Have you used -n option (https://linux.die.net/man/1/ssh)? |
@havalli - Any update on this? can this be closed? |
Please reopen if required. |
@bagajjal - I teste with -n option. Still same error. How do i reopen this issue? |
Hello, I am experiencing same issue when using -n option with OpenSSH Client version v0.0.21 and OpenSSH Server version v0.0.20 (both on Windows 2012 servers). |
It would be great if you can provide the detailed reproduction steps. |
The ssh command is initiated from CHEF client, I will try to grab the client output with -vvv. |
11476 15:38:13:105 debug3: socket:356, io:0000001F2FA85CE0, fd:5 |
@nellfr - Please let us know how to reproduce this issue.. |
From the Windows system, the CHEF client is issuing this command : |
Hello, were you able to reproduce this issue? I can provide additional information or logs whenever needed. |
Same problem, -n does not help |
You can help to solve the problem, since you need to deploy projects to the Windows server using ssh? |
@nellfr - I tried the command you gave me but couldn't reproduce "GetConsoleMode on STD_INPUT_HANDLE failed with 6". |
@bagajjal , I am executing the ssh command with "-n" can you try with that parameter please? |
hello @rjpackito , I'm not sure to understand the problem you are facing with ssh. Do you observe "GetConsoleMode on STD_INPUT_HANDLE failed with 6" message while running an ssh command ? |
@nellfr Yes, I see the same error during the execution of the script on Gitlab Runner CI/CD . I can not understand what the problem is. Because the SCP command works fine. I really need the SSH to deploy on my remote machine my dotnet core application |
@nellfr - adding "-n", sleep of 5 minutes works perfectly... I didn't see any issue. @rjpackito - This is a ssh client side issue. You can try other ssh clients (putty/Cygwin) if you are blocked. Unfortunately I couldn't reproduce this issue. It would be great if you can provide reproduction steps. |
@bagajjal that is, you can not fix the problem in OpenSSH? Can you install the Gitlab Runner? |
Have you tried other ssh clients? If it works in putty then we can fix in openssh... Right now I can't repro the issue.. I will try the gitlab runner.. Meanwhile try using different ssh client like putty |
@bagajjal I do not know, can putty do xcopy through cmd? |
Encountered this problem myself. It happens when you run SSH as a child process via CreateProcess and stdhandles are being redirected. I executed this command as an example: The return code signals, the command was successful, the output to stdout is like you would expect it, but you get output to stderr. If you put a binary zero into the hStdInput of STARTUPINFO, you will get the following output on StdError: If you put a handle to a file or /dev/null into the hStdInput of STARTUPINFO, you will get only It seems that with the option "-T" some code still tries to get the console capabilities using GetConsoleMode, which fails on file handles and triggers this error being written to stderr. https://serverfault.com/questions/593399/what-is-the-benefit-of-not-allocating-a-terminal-in-ssh https://docs.microsoft.com/en-us/windows/console/getconsolemode Hope this helps to fix the problem. |
@anrose00 can you share a snippet of your code doing CreateProcess(ssh) with io redirection ? |
Created a simple wrapper that simply passes the first argument to CreateProcess. This way you can write in a shell "sshwrap "ssh -n -T user@server cmd".
|
Issue ist still present in Release 7.9.0.0 - please reopen. |
Looked into this. It seems that GetFileType on hStdIn (that's pointing to a nul device) is returning FILE_TYPE_CHAR - that's making ssh.exe think that its a console handle, but when the actual console IO is preformed on this handle, it fails resulting in that log. We'll need to investigate if this behavior is by design and accommodate if necessary. To unblock, you could use a pipe handle (from CreatePipe()) for hStdIn whose other end of the pipe is closed. |
Quoting from the ssh man pages regarding the "-n" option:
Perhaps it's possible to make console IO for stdin dependent on this option? |
I changed the minimal example to give the proposal with pipes a try.
This seems to work for Windows 7 systems, but not for Windows 10. On Windows 10 I'm still getting the "GetConsoleMode on STD_INPUT_HANDLE failed with 6" although the file type for STD_INPUT_HANDLE is now "FILE_TYPE_PIPE". |
I tried your code on a Windows 10 box and it works fine. I also tried |
I get the same error within a ci job with gitlab runner, executed manually:
when executed in the pipeline:
No difference when I add the |
Hi All, |
I installed OpenSSH 8, used -n option, add 5 minutes timeout, switched to git ssh, still stuck at "GetConsoleMode on STD_INPUT_HANDLE failed with 6" and the job will hung for long time. |
Related to #1330 ? |
If you are doing these in Windows, there's this file permission issue, that you need to disable inheritance then add the current user in the permission of the ssh config file. After that I think I got that problem solved. Somehow if your computer name is the same as user name, it also has problem. |
Just to throw another data point out there, I'm having this issue with OpenSSH 7.9p1 - getting the 'STD_INPUT_HANDLE failed with 6' issue from a Jenkins runner. It executes the remote command I ask it to, but hangs forever. If I run the same command, same user, from outside of Jenkins, there are no issues. I have not been able to try with 8.x yet. If I add -vvv to ssh, it appears to be hanging during the cleanup of the socket. |
@rcarmich - For interactive ssh session we need to get the stdin handle. |
@bagajjal Yeah, have tried -T without success. Also making things more complicated, the same ssh command works inside the Jenkins runner in a development environment but not on our production Jenkins setup - same Jenkins version, same OpenSSH version, etc. Very bizarre. |
I'm having the same issue as well. I'm using circle ci to deploy my .Net Core console app to a windows server (a bare-metal server) |
Please answer the following
"OpenSSH for Windows" version
0.0.18.0
Server OperatingSystem
0.0.18.0
Server 2016 Core
What is failing
ssh user@server remoteComand
Expected output
no Error
Actual output
GetConsoleMode on STD_INPUT_HANDLE failed with 6
The command is executed in a CI/CD Pipeline by a gitlab-runner. If I execute the command manually inside a cmd window there is no error. The error don't occure with previous version 0.0.17.0.
The text was updated successfully, but these errors were encountered: