Reputation: 2599
I use vscode with remote-ssh to connect my server, after configuring, I want to connect my host, but it failed, the dialog box display:"could not establish connection to XX, The process tried to write to a nonexistent pipe."
output:
[16:45:20.916] Log Level: 3
[16:45:20.936] [email protected]
[16:45:20.936] win32 x64
[16:45:20.944] SSH Resolver called for "ssh-remote+aliyun", attempt 1
[16:45:20.945] SSH Resolver called for host: aliyun
[16:45:20.945] Setting up SSH remote "aliyun"
[16:45:21.012] Using commit id "c47d83b293181d9be64f27ff093689e8e7aed054" and quality "stable" for server
[16:45:21.014] Install and start server if needed
[16:45:21.019] Checking ssh with "ssh -V"
[16:45:21.144] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[16:45:21.214] Running script with connection command: ssh -T -D 5023 aliyun bash
[16:45:21.221] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[16:45:21.504] >
>
>
> ]0;C:\WINDOWS\System32\cmd.exe
[16:45:21.505] Got some output, clearing connection timeout
[16:45:21.577] >
>
>
>
[16:45:21.592] > Bad owner or permissions on C:\\Users\\DY/.ssh/config
>
[16:45:21.689] > The process tried to write to a nonexistent pipe.
>
[16:45:22.091] "install" terminal command done
[16:45:22.092] Install terminal quit with output: The process tried to write to a nonexistent pipe.
[16:45:22.093] Received install output: The process tried to write to a nonexistent pipe.
[16:45:22.096] Resolver error: The process tried to write to a nonexistent pipe
[16:45:22.107] ------
Upvotes: 97
Views: 156852
Reputation: 2599
Go to remote ssh setting:
Ctrl+Shift+p
and enter remote-ssh: settings
Add the absolute file path to a custom SSH config file(C:\Users\{USERNAME}\.ssh\config), and my problem is solved.
Upvotes: 113
Reputation: 583
In Windows 10, I resolve the issue by setting config file and crtl+shift+p and enter remote-ssh to open settings and set "Config File" as follow:
/c/Users/{USERNAME}/.ssh/id_ed25519.pub
Upvotes: -1
Reputation: 1276
Make sure you have ssh-server installed on the server you want to connect to.
sudo apt update
sudo apt install openssh-server
I successfully wasted my 4 hours because of it.
Upvotes: 0
Reputation: 391
If you're using WSL and might think that you should update ~/.ssh/config
, that might not be the case.
~/.ssh/config
C:\User\xxx\.ssh\config
windows fileC:\User\xxx\.ssh\
and is listed in configUpvotes: 1
Reputation: 1
Novice coder here. I had this problem "process tried to write to a nonexistent pipe." Tried various changes to VS Code, EC2 instance, and deleted known_hosts file. Turns out I was getting "access denied" because day before I had added another user to my username as a linux group (I was learning how Groups works). When I removed the other user from the group ("$gpasswd -d user2 user1"), my ssh issues were resolved.
Upvotes: 0
Reputation: 31
I had this problem once.
All you need to do is,
Go to /Users/XXX/.ssh
if you are on the windows, use command : "del /f known_hosts" to delete the known_hosts on the command prompt.
3.Then go to C:\Users\XXX.ssh\config on the vs code( config file )
4.Delete the host and the user if the host that you are trying to connect to is already there.
5.Then try to connect to the new host as usual.This will work.
The problem here could the mismatch of the finger prints once you reinstall the OS o n your host machine. So to solve this problem by deleting the host that was saved.
once the config file on the vs code is edited it should look like..below picture is to show how the config file should look(after deleting the host saved)
Upvotes: 2
Reputation: 41
WSL Related
In my case, the issue was that my keys were set up on Ubuntu on WSL and VS Code was looking for them in Windows. I copied the keys over from the WSL side to Windows and voila! Worked like a charm!
Steps that I took.
Upvotes: 0
Reputation: 1
In my case it worked when I added the port in my expression, eg ssh user@host-or-ip -p 22
. With '22' the default port number, but you can check which port the ssh system is listening on with the sudo service ssh status
command.
Upvotes: 0
Reputation: 11
This seems to be a general error when the ssh connection fails for one of a multitude of reasons.
Adding what my issue was, and what helped, because I don't see it in the other answers in here: I had re-installed the box I was connecting to, and with it, reset the key it was using to authenticate. The ssh process tried to connect and failed with the usual "someone might be MITMing you this very moment, the identification changed" error, visible in the VSCode terminal. Solution was to go to my authorized_keys file and remove the offending key.
Obviously only know that if you know for sure why the identification changed, and that it's harmless. Don't actually get MITMed.
Upvotes: 1
Reputation: 13582
At least three things may be happening:
Option 1
The location of your config file is not the absolute location, meaning you are probably using the location of the folder where the config file is.
If that is the case, access your User Settings in VSCode. Scroll to the Extensions
>Remote - SSH
. And add config
at the end of the absolute file path of your custom SSH config file. In Windows, it can be
C:\Users\user\.ssh\config
See image below
Option 2
Authentication problems.
If that is the case, one of the things that may solve is generating new SSH keys.
In Windows, for that, I recommend using MobaXterm.
In MobaXterm, open a new terminal and write
ssh-keygen -b 4096 -t rsa
Then, in the config file, make sure that the IdentityFile
points to the location of the key. MobaXterm's home directory, usually, is C:\Users\user\Documents\MobaXterm
. If it makes it easy, one can copy/move the keys to C:\Users\user\.ssh
and then just add, in the config file, IdentityFile ~/.ssh/KEY_rsa
(where KEY_rsa
is the name of the [public] key).
Note that if you use PuTTY to generate the keys, on the server OpenSSH authorized_keys file, one doesn't want the public key that one saves, but the one that appears on top (see image bellow):
Option 3
Your config
file may be wrong.
The config file tends to look as follows. Double check if the fields have the information needed for the connection to be established.
Host Test # This is the name we want to give the host
User user # This is the username
Hostname blabla.com # This is the hostname
PreferredAuthentications publickey
IdentityFile ~/.ssh/KEY_rsa # This is the location of the key
IdentitiesOnly yes
Port 50 # This varies
Upvotes: 15
Reputation: 1245
The solution below may be the last resort but it perfectly solved the issue for me in a Windows 10 local machine. I simply delete the known_hosts file under the directory C:\Users\[your-username]\.ssh
, relaunch VS Code and reconnect the remote server through Remote Explorer. Everything works normally afterward.
Upvotes: 2
Reputation: 181
And for yet another seeming cause/solution:
Connecting to the server using another client, I attempted to rm -rf ~/.vscode-server
. I could not delete many of the files because "device or resource busy".
That eventually required doing the following:
fuser ~/.vscode-server/[one of the child files ...]
. But, you can probably skip this, because mainly I needed to know what to search for. Plus, fuser
and lsof
were finicky about returning results -- they often just sit waiting for something, I don't know what.ps -e | grep node
since node is the running process using vscode-server files.ps -o user= -p PID
, substituting PID with each process PID in turn. This creates a formatted list of the process's associated user.kill -9 PID
. You won't need to run this for all PIDs, because killing a lower PID killed a child PID after a few seconds. So keep checking which node processes still exist after killing one: ps -e | grep node
rm -rf ~/.vscode-server
known_hosts
, it even asked to confirm the connection to the server (up top, in the command prompt).Also, for reference, I left the remote-ssh: settings config file entry, mentioned in other solutions, blank.
For reference or further explanation of certain steps above (I don't intend to elaborate more than I did):
rm: cannot remove ‘.vscode-server/bin/xxxxxx/.nfs000000000xxxxxxxxxxxx’: Device or resource busy
How find out which process is using a file in Linux?
https://unix.stackexchange.com/questions/284934/return-owner-of-process-given-pid/284938
Upvotes: 0
Reputation: 5292
There can be several reasons that have nothing to do with the accepted answer. For me:
Upvotes: 0
Reputation: 598
Mine was solved by adding ".pem" extension while specifying the private key. Here's the sample config text for reference.
Host ec2-3-234-8-176.compute-1.amazonaws.com
HostName ec2-3-234-8-176.compute-1.amazonaws.com
IdentityFile ~/.ssh/privatekey.pem
User username
Upvotes: 0
Reputation: 1587
In my case it was because the name I gave the host in config
was myuser@myhostname
. So if your config
file looks like this:
Host myuser@myhostname
HostName 12.64.88.234
User myuser
Port 22
Try changing it to this:
Host myuser
HostName 12.64.88.234
User myuser
Port 22
Upvotes: 0
Reputation: 356
For Windows:
Adding the escape character before the private key file name & using quotes around the path solved my issue.
//config file
Host 12.12.12.12
HostName 12.12.12.12
IdentityFile "C:\Users\USERNAME/\PRIVATEKEY" <----Note /\
User username
Upvotes: 3
Reputation: 11
A possible solution:
First run cat $HOME/.ssh/id_rsa.pub
on your computer. That will get you a key. Save this key somewhere.
Then open this file by running vim $HOME/.ssh/authorized_keys
on the computer that you're are ssh'ing to. Then copy the key in a new line of this file and close it by typing :wq
.
You are all set.
Upvotes: 0
Reputation: 41
The solution in my case was editing the json settings file for VSC as shown here: https://code.visualstudio.com/docs/remote/troubleshooting#_troubleshooting-hanging-or-failing-connections In VSC go to File, Preferences, Setting and click on the upper right hand icon (Open Settings, JSON). Add these two lines to settings.json and retry connecting:
"remote.SSH.showLoginTerminal": true,
"remote.SSH.useLocalServer": false
Upvotes: 4
Reputation: 2048
I really didn't want to delete my C:Users\valo\.ssh\config
, so I played a little with the various entries. It turned out that for me the option IdentitiesOnly yes
was the problem. I also disabled security inheritance on all key files in the .ssh
folder and left only myself, with Full Rights
. Here is what my C:Users\valo\.ssh\config
looks like now:
CanonicalizeHostname yes
Host aws.r3
HostName 3.31.45.216
ForwardAgent yes
User ubuntu
IdentityFile C:Users\valo\.ssh\u1-client-20210203-090555.pem
# IdentitiesOnly yes # VSCode Remote doesn't like this flag...?
Host github
HostName github.com
User git
IdentityFile ~/.ssh/id_val_ed25519
Host github.vm
HostName github.com
User git
IdentityFile ~/.ssh/id_valo_ed25519
Host *
ForwardAgent yes
AddKeysToAgent yes
LogLevel FATAL
ChallengeResponseAuthentication no
Now I can connect to aws.r3
with VSCode Remote.
Upvotes: 0
Reputation: 31
In my case, I did what dalilander said, but instead of deleting the entire '.ssh' folder, I just needed to delete the file 'known_hosts' and then it worked. So the servers I had saved were not deleted.
The path of that folder is C:\Users\yourUsername\.ssh
Upvotes: 2
Reputation: 81
In my case, I had no internet connection.
I was connecting to the server via VPN but the remote configuration was incorrect and I couldn't access the server. (DNS related issues) The connection indicator was showing no errors, so I didn't think of that at first.
Oops :)
Upvotes: 0
Reputation: 25
Trying to add the full path in "IdentityFile" made the trick
" IdentityFile C:\Users\xxx.ssh\xxx"
Upvotes: 1
Reputation: 429
This seems to be a problem with varied causes and corresponding remedies. In my case the problem had to do with the version of ssh I was using. In my Windows path there were two places were an instance of ssh.exe resided:
C:\Program Files (x86)\OpenSSH\bin
C:\WINDOWS\System32\OpenSSH\
After using both paths to set the "Remote.SSH: Path"
parameter (which is in "Remote.SSH: Settings"
[see here]), i.e. first C:\Program Files (x86)\OpenSSH\bin\ssh.exe
and then C:\WINDOWS\System32\OpenSSH\ssh.exe
, the problem still persisted.
Then I looked at this and tried the git-provided ssh.exe, which I already had on my system (otherwise, just install git, it's good stuff anyway :) )
Setting the SSH path parameter with that version did the trick for me, i.e. setting path to:
C:\Program Files\Git\usr\bin\ssh.exe
Upvotes: 2
Reputation: 1
For me, (windows) the permissions on the .pem file were the Critical issue. I had Administrator group only on the pem file and it was not working. I had to explicitly add the Admin user as well (even though admin is of course in administrator group).
Upvotes: 0
Reputation: 2174
This is probably something everyone has tried before looking here, but it worked for me. The server I was trying to ssh into was not responding, leading to the nonexistant pipe error. I rebooted the server and everything worked fine.
Upvotes: 3
Reputation: 1579
What worked for me:
C:\Program Data\ssh
and C:\<user>\.ssh
F1
, choose Remote-SSH: Connect to Host...
+ Add New SSH Host..
ssh -i "C:\path\to\key" user@host
. (you need to make sure the key has a limited permission. Remove all inherited permissions, and only give a full control to the owner.)connect
Upvotes: 13
Reputation: 341
OS: windows 10
In my case there were permission issues. Repeatedly changing inheritance in windows did not solve the issue. Finally this worked
change the folder in which the config file is stored.
From C:/users/usr/.ssh/config
to D:/config
and changed the config path in vscode remote ssh settings.
This worked for me.
Upvotes: 2
Reputation: 1484
In my case this was an offending key in my known_hosts in Windows (vscode on windows, remote developing via ssh on linux).
The error that comes back in vscode is not explaining in any way.
Upvotes: 0
Reputation: 1243
In my case I had another setup:
Problem: the ssh.exe is using a different path convention thant VSCode. ssh.exe is using the "/c/Users/..." pattern and VSCode is using the "C:\Users..." pattern.
Solution:
VSCode will still be able to access the settings using the standard path, and the ssh.exe configuration will still look at the same standard path so the connexion is working.
Note:
I have the error only when connecting with multiple ssh servers (using ProxyJump). When connecting only to the first server, the solution of @pszrux and this one are both working for me.
Upvotes: 3