“This is the 10th day of my participation in the First Challenge 2022. For details: First Challenge 2022.”

preface

This is a transcript of my previous blog post on CSDN. VScode builds a remote Python environment

The installation

First, install the remote-SSH plug-in.Then, press Ctrl + Shift + P to open the command panel, type Connect to Host, and select the first command:

Select Add New SSH HostThen enter the remote address and login account as prompted.

Here select the SSH configuration file under the user name directory of our computer. If not, you need to open the SSH function of the computer first. SSH has been supported in the function of Win10, which can be very convenient to open. Reference: Installing OpenSSH,link Then right-click and select Connect.

– Remote SSH in VScode uses Windows username instead of ssh_config

After the above configuration, everything was fine the first time I connected to the remote host. However, when I later added other remote nodes, I found that VScode automatically connected using the Windows computer’s own host name instead of the login account name I configured in the file. After some searching, a solution was found, which was recorded as follows:

First, we open the file C:/Users/your_username/.ssh/config and add all the Host names in it to our login account names. The following is an example:

Host 10.10.10.1
  User usename
  HostName 10.10.10.1
Copy the code

Instead of

Host [email protected]
  User usename
  HostName 10.10.10.1
Copy the code

In this way, you can use the configured account name to log in each time.

Secret free login method

After the above configuration, you need to enter the password every time you connect to the remote host, which is very troublesome. We can configure a secret free login to facilitate the connection.

First, you need to use ssh-keygen -t rsa to generate a pair of keys, id_rsa and id_rsa.pub, in the local user directory (C:/Users/your_username/.ssh/). If the file already exists in the local directory, you do not need to regenerate it. See vscode to avoid entering a password every time you SSH

We then append the contents of the generated id_rsa.pub file to the authorized_keys file (if you don’t need to create it yourself) in the /home/usernam/.ssh/ directory on the remote server. After that, you can achieve secret – free login.

Fix for ‘Bad owner or permissions’ and vscode” pipe that remote host remote SSH procedure was trying to write to does not exist”

After the above configuration, my VScode is normal in a few days, but because the computer user name is set in Chinese, there are some errors. So after I changed the Windows user name back to English, VScode could not be connected. The terminal keeps reporting ‘Bad owner or permissions’ and vscode” the pipe that the remote host remote SSH procedure was trying to write to does not exist “.

WIn10 OpenSSH has a problem. The solution is to change the system environment variables

%SystemRoot%/openssh
Copy the code

The SSH directory in git installed on your computer is:

D:\Program Files\Git\usr\bin
Copy the code

reference

[1] Visual Studio Code Remote SSH uses Windows username instead of username in ssh_config, link

[2] Windows 10 SSH perfect fix ‘Bad owner or permissions’ and vscode” remote host remote SSH process attempt to write pipe does not exist “, link