vscode cant ssh connect "The process tried to write to a nonexistent pipe" - ssh

I am able to ssh on my windows 10 computer using ubuntu subsystem when I run the command:
/mnt/c/Users/marti/Downloads$ sudo ssh -i credfile.pem ec2-user#3.333.33.333
Where I have a file located at /mnt/c/Users/marti/Downloads/credfile.pem
I am trying to get VSCode's ssh extension to work but it keeps failing with an error "The process tried to write to a nonexistent pipe"
In my vscode settings it points to my ssh config file:
In order to connect I click the green bottom left corner of my vscode window and select the first option 'remote-ssh connect current window to host'
I paste in my command, hit enter, it prompts me to choose either mac/win/linux and I pick linux.
But it then just leads to an error saying it tried to write to a nonexistent pipe?
[20:50:27.876] "install" terminal command done
[20:50:27.877] Install terminal quit with output: The process tried to write to a nonexistent pipe.
[20:50:27.877] Received install output: The process tried to write to a nonexistent pipe.
[20:50:27.883] Resolver error: Error: The process tried to write to a nonexistent pipe
Is there something else I need to setup or change for my vscode ssh connection to work?

Instead of pasting your command, you should code the same command in your .ssh/config file.
Add in it:
Host ec2
Hostname 3.333.33.333
User ec2-user
IdentityFile C:\path\to\credfile.pem
Then you will be able to select the entry 'ec2' after selecting 'remote-ssh connect current window to host'

Related

Starting WSL with SSH command from cmd

I am setting up hotkeys currently with AutoHotKey, inside I run the line "Run "C:/Windows/System32/wsl.exe ssh host#ip"
What this does it load that file and pass it that command as if you were to load it in CMD and run "<program path> <command>"
The issue starts here. If I have WSL open, my keychain is loaded and I can ssh to the IP, however running it from a CMD (or in this case AHK loading the file with the command) it throws a publickey denied error as "technically" its not ACTUALLY inside WSL yet.
I haven't found a workaround/anything that could make this work
I am expecting this to open up wsl and THEN run the ssh command, not try to do it all straight away because then the keychain isn't loaded
TL;DR
Trying to open wsl with via "C:/Windows/System32/wsl.exe ssh USER#HOST" being run in CMD/Batch File, this gives publickey denied as its not technically loaded up the keychain in WSL yet

VSCode Remote-SSH Cannot Connect

I'm trying to use the Remote-SSH extension to edit files on a Linux server from my Windows 10 development machine. Normally, I log into the server using VNC and edit files locally OR I use WinSCP to pull the files to my development machine and copy them back over when done. The Remote-SSH extension seems to be the answer to this inefficiency.
I can SSH just fine using Putty or using Git Bash, but Remote-SSH fails to connect. There's some hints in the error message, but I'm not sure how to interpret them.
Here is my SSH config file (redacted) and the error I receive (redacted):
Config:
Host xxx.yy.gov
HostName xxx.yy.gov
User myusername
Error Message:
[08:44:36.981] remote-ssh#0.47.2
[08:44:36.981] win32 x64
[08:44:36.983] SSH Resolver called for "ssh-remote+xxx.yy.gov", attempt 1
[08:44:36.983] SSH Resolver called for host: xxx.yy.gov
[08:44:36.983] Setting up SSH remote "xxx.yy.gov"
[08:44:37.030] Using commit id "[some-string-of-numbers]" and quality "stable" for server
[08:44:37.033] Testing ssh with ssh -V
[08:44:37.101] ssh exited with code: 0
[08:44:37.101] Got stderr from ssh: OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
[08:44:37.105] Running script with connection command: ssh -T -D 52772 xxx.yy.gov bash
[08:44:37.107] Install and start server if needed
[08:44:37.111] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[08:44:37.264] >
[08:44:37.264] Got some output, clearing connection timeout
[08:44:37.611] > myusername#xxx.yy.gov's password:
[08:44:37.612] Showing password prompt
[08:44:44.709] Got password response
[08:44:44.709] "install" wrote data to terminal: "**************"
[08:44:44.730] >
>
[08:44:45.102] > bash: bash: command not found
>
[08:44:45.476] "install" terminal command done
[08:44:45.476] Install terminal quit with output: bash: bash: command not found
[08:44:45.476] Received install output: bash: bash: command not found
[08:44:45.477] Stopped parsing output early. Remaining text: bash: bash: command not found
[08:44:45.477] Failed to parse remote port from server output
[08:44:45.477] Resolver error:
[08:44:45.480] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"UnparsableOutput",
"askedPw":"1","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","gotUnrecognizedPrompt":"0",
"remoteInConfigFile":"1"},"measures":{"resolveAttempts":1,"retries":1}}
[08:44:45.482] ------
VSCode Remote-SSH error
There are there are three ways you can try. I know the problem is annoying.
Check your vscode is local window or remote window. Then, check
remote-ssh setting. (Make sure Local Server Download is auto && Use
local Server is marked.).
Remote SSH:Path . you can switch to local ssh or git/ssh
Try to update or revert remote-ssh.(Version 0.50 can connect to server host stably, I found. This one is very useful.
Maybe you just select 'Linux' instead of 'Windows' though you are using Windows when you got the option to select Linux, Windows or Mac.
Since you are connecting to a server and not your own computer, the type of server you are connecting to is most likely Linux.

Start SSH connection in PuTTY, run a command, and leave the session active

I want to run a few shell commands every time I SSH to a server via PuTTY. I'm connecting to a production web server managed by someone else, and I don't want to store my own scripts there.
I see the option Connection > SSH > Remote Command, but if I put my initialization commands there, after starting the session, it closes immediately after the commands execute. How can I run the Remote Command, and then keep the session open so I can continue using it?
The SSH session closes (and PuTTY with it) as soon as the command finishes. By default the "command" is a shell. As you have overridden this default "command" and yet you want to run the shell nevertheless, you have to explicitly execute the shell yourself:
my-command ; /bin/bash
See also Executing a specific command on the server.
One option to go is set up your putty remote command like this:
ls > dir.ls & /bin/bash
In this example command you want to run is "ls > dir.ls" what creates file dir.ls with content of directory listing.
And as you want to leave shell open you can add aditional command "/bin/bash" or any other shell of your choice.

'xterm-new': unknown terminal type

Replicating the error:
I am using iTerm2 on Macbook (OS X Yosemite)
I ssh into a remote instance and tried to run the clear command and this error is shown:
'xterm-new': unknown terminal type.
Not only for the clear command but the same error is displayed for several other commands and the command does not execute as expected.
The error occurs only when I use iTerm2 and not when I use the default Mac Terminal. So I am guessing this problem has something to do with iTerm2 and not the virtual machine.
How can I solve this problem with iTerm2?
As mikyra pointed out in the comments above, setting the environment variable TERM=xterm-256color solves the problem.
To summarize:
# Run the following commands on the local machine's bash prompt
echo "export TERM=xterm-256color" >> ~/.bashrc
source ~/.bashrc
ssh into remote machine and run the commands you like. The same xterm-new error should not occur now.

Passing shell script file

I have a linux shell script file which collects various data from linux server. (Services, Process, FreeSpace etc.).
From windows to collect the data we are using Plink to connect to linux Boxes and run the shell script
plink root#servername -pw Password -noagent -m Batch-File.
and using pscp to copy the file to windows location.
Now when I try to do the same for Esxi the plink command fails with the error below.
FATAL ERROR: Server unexpectedly closed network connection
though If i give a direct command as below.
plink root#servername -pw Password -noagent ls /etc
works out.
Let me know how to use the plink for esxi .. if possible.
After seeing the messages log it looks like that the issue is with esxi's limitation to read long character string. The message log fails in the session with String Too Long and then post a message of closing the connection.
Thus the approach was to copy the shell script as a pscp connection, run the file with executable permission and collect the data gathered and delete the file from system.