Sean Zamora
Sean Zamora

Reputation: 247

How do I resolve "Failed to parse remote port from server"?

I'm setting up a new remote host and every time I initiate it I get the following error output. How can I resolve this issue?

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

Linux Destiny 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1 (2019-04-12) x86_64

The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

mesg: ttyname failed: Inappropriate ioctl for device

bash: cannot set terminal process group (3202): Inappropriate ioctl for device bash: no job control in this shell

mesg: ttyname failed: Inappropriate ioctl for device

Installing... Downloading with wget

WARNING: tar exited with non-0 exit code

Found running server...

*

cat: /root/.vscode-remote/.473af338e1bd9ad4d9853933da1cd9d5d9e07dc9.log: No such file or directory

Server did not start successfully. Full server log: cat: /root/.vscode-remote/.X.log51ec4692- 4da4-4ec0-b613-5a3563034cf1==== : No such file or directory

"install" terminal command done Received install output: : No such file or directory Failed to parse remote port from server output: : No such file or directory

Upvotes: 19

Views: 88068

Answers (20)

ben
ben

Reputation: 1468

For me this was caused by the host running out of disk space.

Upvotes: 1

Sharath
Sharath

Reputation: 1

If you are using the windows machine, following steps resolved the issue for me. go to following path. C:\Users<username>.ssh

In here remove known_hosts and known_hosts.old file and then try to reconnect.

Upvotes: 0

Shunhong Zhang
Shunhong Zhang

Reputation: 1

Change your shell to bash temporarily. vim /etc/passwd and change your shell to bash. You can restore your prefered shell after vscode remove has been initialized on target server

Upvotes: 0

Michael Riepe
Michael Riepe

Reputation: 1

I was getting the same error message after VSCode auto updated to version 1.87.2. In my case the solution was to disable the setting "Remote.SSH: Use Exec Server".

Upvotes: 0

GTA_Stover
GTA_Stover

Reputation: 1

When attempting to SSH into a remote host, if you encounter an issue where the connection fails with an error message, it's possible that the host's key has changed since the last connection. One solution to resolve this issue is to remove the entry associated with the remote host from the known_hosts file.

Here are the steps to follow:

  1. Locate the known_hosts file on your local machine. This file is typically located in the .ssh directory within your home directory.

  2. Open the known_hosts file using a text editor.

  3. Search for the entry corresponding to the remote host that you are trying to SSH into.

  4. Delete the entire line containing the entry for the remote host.

  5. Save the changes to the known_hosts file.

  6. After removing the outdated entry from the known_hosts file, you should be able to SSH into the remote host without encountering any further issues.

Upvotes: 0

Ou Ni
Ou Ni

Reputation: 41

An alternative way to follow this solution is to use the uninstaller of remote-ssh extension. First, use [Ctrl + P] and type [> remote-ssh uninstall]. Then, selecte the uninstall option and choose the server where this error occurred. The relevant lockfile will be automatically deleted. If there is a permission error in the VSCODE [output] window, you can use sudo permission to remotely delete this file through ssh.

Upvotes: 2

Matt Gaunt
Matt Gaunt

Reputation: 9831

For folks with a Mac OS X host, I ran into this error message and I suspect it's caused by Mac's change to ZSH for the default shell (See here: https://support.apple.com/en-us/HT208050).

  • Go System settings, click on Users & Groups
  • Control-click the user name you want to change the login shell for and click on advanced options
  • Change the login shell to /bin/bash
  • On the host kill all servers:
    kill -9 $(ps aux | grep vscode-server | grep $USER | grep -v grep |
    awk '{print $2}')
    
  • On the host delete all server downloads:
    rm -rf $HOME/.vscode-server # Or ~/.vscode-server-insiders
    

After doing this I was able to reconnect (maybe took one or two attempts).

NOTE: The kill and rm -rf commands are from these vscode docs

Upvotes: 0

user3503711
user3503711

Reputation: 2096

The following solution worked for my case:

  1. Connect to your server through a terminal (vscode terminal, cmd etc)!
  2. Remove vscode-server from /home/user_name/ folder. (rm -r /home/user_name/.vscode-server)
  3. Try connect from VS code again!

The server will be re-installed. However, you loose config, meta data etc.

Upvotes: 1

KingLiu
KingLiu

Reputation: 305

There are many causes for this problem,

  • First, ensure the ssh is working, whatever you can restart the ssh
/etc/init.d/ssh restart
  • Then, delete the lock files
rm -rf ~/.vscode-server/bin/**
  • Finally, retry connecting

Upvotes: 11

Sachin
Sachin

Reputation: 1704

I also got the same issue and my workaround was to provide proper rights to the home or user folder, so Visual Studio Code can create a remote folder and do the required installation on it.

Example:

sudo chmod -R 777 /home/

In this case, I have provided all rights to my home folder (777) and it worked like a charm for all the users.

Upvotes: 0

Raul Rodriguez Arias
Raul Rodriguez Arias

Reputation: 21

Sachin's answer directed me in the right direction. Visual Studio Code needs permissions in order to create some files, but instead of giving 777 permissions to your home folder (which can be dangerous), you can just chown the user that wants to log in (the user for me was ubuntu):

sudo chown -R ubuntu /home

I also got the same issue and my workaround was to provide proper rights to the home or user folder, so Visual Studio Code can create a remote folder and do the required installation on it.

Upvotes: 1

Solo.dmitry
Solo.dmitry

Reputation: 780

If you authorize by ssh-key, also check the value of the User parameter in Visual Studio Code's SSH configuration. User must have a matching key in file ~/.ssh/authorized_keys on the remote host.

Upvotes: 0

Shruthi H R
Shruthi H R

Reputation: 7

Step 1: Add port to your configuration file:

Host hostname
Port 22
User username

Step 2: Go to menu FilePreferencesOpen settings.json file. Search for lockfilesInTmp and check the box next to that

Upvotes: -2

randUserbruh242
randUserbruh242

Reputation: 1

In my case, it wasn't working because of the server asking for a new password when starting a session. I opened a new default terminal (not the Visual Studio Code terminal, but your OS default terminal, like Z shell, CMD, and so on). And I used the ssh command to log in. I logged in successfully and changed the password. Then I tried connecting with the new password and it worked, because the server didn't asked for a password change now.

Command:

ssh username@IP

Enter the password and you'll get asked to change the password. Change the password and try connecting again with new password using the SSH Visual Studio Code extension.

Upvotes: 0

kauii8
kauii8

Reputation: 229

I had the same issue because Visual Studio Code was looking for my .vscode-server directory in the wrong location (it was in a custom location due to restrictions on where files can be saved). This can be fixed by using How to change vscode-server directory. Specifically, add

"remote.SSH.lockfilesInTmp": true,
"remote.SSH.serverInstallPath":{
    "hostname":"/path/to/.vscode-server/.."
}

to your settings.json file.

Upvotes: 1

Finn
Finn

Reputation: 111

I ssh'd onto the remote server (Linux) and then deleted both directories as follows:

rm -r .vscode-server.backup2022-04-03T16:20:18-05:00

rm -r .vscode-server

Upvotes: 5

Greg
Greg

Reputation: 1989

In case someone else encounters the same issue: I had an instance where the remote target didn't have any space left on the device. After extending the root volume of the target machine, the connection worked fine.

Upvotes: 0

Sean Zamora
Sean Zamora

Reputation: 247

I fixed the issue. It appears I had two other server agents running incorrectly. I killed both server agents using kill (PID) and removed the ".vscode_remote" directory from the user home directory. Then I reinitialized remote-ssh from Visual Studio Code. Successfully connected!

Upvotes: 2

bodo
bodo

Reputation: 847

On the remote machine you do not have a tar file installed. It's in the log output

Installing... Downloading with wget

WARNING: tar exited with non-0 exit code

so under a root run:

apt-get install tar

or with sudo, if you have a user with sudoers configured:

sudo apt-get install tar

Upvotes: 1

Floegipoky
Floegipoky

Reputation: 3273

If the server fails to shut down properly, sometimes it leaves dangling lockfiles. This can cause startup to fail and produce the "Failed to parse remote port from server output" error message. In this case the solution is to simply to delete the lockfiles:

.vscode-server/bin/[:xdigit:]*/vscode-remote-lock.*

Upvotes: 21

Related Questions