VSCode: how to use ssh key to log in remotely to the server & configure the interpreter without secret

created at 08-08-2021 views: 43

1. Use the ssh key to log in to the server remotely without secret

If you have not successfully logged in to the server remotely, the following blog may be helpful to you

VSCode remote connection server reported an error: Could not establish connection to "xxxxxx" [Solved]

If you have successfully logged in to the server remotely, Let’s start!

1. Enter in the terminal of VSCode


Keep pressing Enter until it appears:

key information

At this time you will have a pair of private key and public key, the path is:


If not found in the above path, you can log in to the remote server and find the above two files in /home/user_name/.ssh/. At this time, it is best to copy the two files to C:\Users\user_name.ssh\.

2. Log in to the server remotely, enter /home/user_name/.ssh/, copy the content in id_rsa.pub to authorized_keys (if not, please create it yourself), and save it. (The path of the .ssh eventually found on the remote server may be different, you can find it yourself)


3. Back to VSCode, add the private key information in the Remote-SSH config file:

IdentityFile "C:\Users\user_name\.ssh\id_rsa"

add the private key information in the Remote-SSH config file

4. After saving, you can turn it off and log in again to see if you need to enter a password.

2. Configure the interpreter

Prerequisite: Anaconda has been installed

2.1 In file–preferences–settings in VSCode:

settings in  vscode

Enter python.pythonpath in the search box, and fill in the Anaconda installation path in the input box below


If python.pythonpath cannot be found in the search box, remember to install python and code runner in Extensions first.
2.2 You can also search for python and modify it in settings.json:


Add python.pythonpath information:

Add python.pythonpath information

2.3 Select a specific interpreter: control+shift+P, enter Python: Select Interpreter in the input box and press Enter to select the environment.

select environment

2.4. Finally, you can write a few lines of simple code and run it to verify whether it is successful.

created at:08-08-2021
edited at: 08-08-2021: